People occasionally ask me why tmux
is significantly better than screen
, and I end up mumbling the first few things that come to mind. This has yet to sway anyone. Here, then, are some things that I enjoy about using tmux
.
First, some terminology, so the rest of this makes any sense at all.
tmux
andscreen
, if you were not aware, are multiplexersâthey let you run multiple terminals (or terminal programs) at the same time, switch between them, and disconnect or close your terminal without killing everything you were running. If you didnât know this then you should probably stop now and poke around tmuxâs site or something.- A session is a particular group of terminals owned by
tmux
(orscreen
). When you runtmux
bare, you get a new session. - A window is a numbered terminal inside a session.
- A pane is each compartment within a split window. (I lied above; a window might actually have several panes and thus several terminals. But a window is identified by one number.)
- An xterm is a single GUI terminal window (or tab). You may be using another terminal emulator, or you may be in a non-GUI virtual terminal; Iâm using âxtermâ as an umbrella term for all of these.
Iâm also assuming that ^A
is your multiplexer trigger key, although tmux
defaults to the more awkward ^B
.
Works out of the box
Hereâs my .screenrc
, fiddled by hand over the course of many months after I started using screen
.
1 2 3 4 5 6 7 8 9 |
|
What the fuck is any of this? The only real configuration here is the first line, which sets a fairly simple status bar. The rest is unreadable sludge picked off of Google to make terminals inside screen
work the same way as terminals outside it. I see this as a serious failing in the one core feature that defines a multiplexer: being invisible.
Some of this might not be necessary any more; maybe termcaps have been improved in the meantime. Part of the very problem is that I canât know; the best I can do is delete bits of it and see if screen
still behaves correctly, assuming I remember all the quirks I was trying to fix in the first place. Itâs 2012. I shouldnât ever see the word âtermcapâ.
Contrast with tmux
, which just worked. The only terminal-related fudging I ever had to do was set my $TERM
to xterm-256color
for it to respect 256-color sequences. Not entirely unreasonable.
tmux
can also inherit parts of the environment when itâs detected a change; by default it looks for some common X and SSH stuff. The upshot of this is that your SSH agent continues to work across SSH connections; the new environment only applies to newly-created windows, but zero hacks are necessary.
By default as of tmux
1.6 (I think), when you create a new window, itâll get the same current working directory as the current window.