Sunday, November 28, 2010

tmux, a BSD alternative to GNU Screen

I started using tmux today. Its a terminal multiplexer / task switcher for UNIX-likes, very much in the same vein as GNU Screen. However, its a from-scratch implementation, designed to be clean, sane and easy to configure. The more liberal 3-clause BSD license is a plus also, since it means that OpenBSD has been able to integrate it into the source tree, so that its available out of the box.

Comparison with GNU Screen

I’ve been a heavy screen user for many years – almost all my work is done on remote screen sessions. However, screen configuration has always been essentially black magic to me. For this reason, tmux and its nice manual page is a breath of fresh air. `tmux list-commands’ is very straight forward and easy to grok. Furthermore, I like that everything in tmux is scriptable from the command line – you can run commands like `tmux resize-pane-up -t comms’ to resize the pane on a session called ‘comms’.

The other thing I really like about tmux is its default status bar. Some people might hate this, but I find it very useful to have a clock and a list of windows along with the process executing in them. This took quite some work to set up to my liking in GNU screen, but the default in tmux is great.

My config

One thing I don’t much like is the default of C-b as the ‘prefix’ command. I suppose this makes some sense, since the author doesn’t want to clobber GNU screen key bindings. Perhaps he will consider changing it to C-a, like in GNU screen, in the future. In any case, this isn’t hard to change. Also, I am constantly using C-a C-a to switch back to the previous window – the default for this action in tmux is C-b l. Much less friendly in my opinion – of course, its also easy to change!

So here are the contents of my $HOME/.tmux.conf:


set -g prefix C-a
bind-key C-a last-window

Getting tmux

I’m sure that packages exist for most operating systems. You can grab the source from http://tmux.sourceforge.net/. On OpenBSD, you can simply run `pkg_add -i tmux’ to get the binary on your system.

UPDATE

Since OpenBSD 4.6, tmux is part of the base system. This means that if you are running OpenBSD 4.6 or later, you don’t need to install any packages in order to get tmux.


Reference: http://niallohiggins.com/2009/06/04/tmux-a-bsd-alternative-to-gnu-screen/

No comments: