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.

14 comments to tmux, a BSD alternative to GNU Screen

  • von Fieer

    I’d very much argue against the use of C-a. C-a is ‘move to the beginning of line’ in Emacs-like command-line editing mode. Emacs being the default editing mode in shells, this was a big mistake on part of the authors of GNU screen.

  • chris

    tmux would be great if only I could use *BSD every where I go; Most of the time I am using Linux, so to get tmux on Linux, I will probably have to compile it from source. OTOH, screen is already there on many Linux distributions; if not, I just install the RPM package.

    For now I’m sticking to screen.

  • niallo

    von Fieer: Thats a good point. Obviously, C-a is not good for Emacs users. I’m a Vi guy so I didn’t think of that. However, I still think C-b is a bad default, because of the nasty finger chording. Gives me RSI just thinking about it :-) Surely there’s something better.

  • niallo

    chris: Its true that screen is already installed on most Linux distros, while tmux isn’t. I too have to log into lots of Linux machines which I don’t necessarily have control over packages on. But tmux is nice enough for me, that I run it in my OpenBSD environments. And I use those environments very heavily, so it works out as a net gain. As for random environments, I’m sure as tmux gains popularity, packages will become available for the usual suspects, so you can get it with a simple apt-get/yum/whatever invocation.

  • tmux is in Debian Sid and Ubuntu Karmic, at least.

  • bllbb

    what i like with tmux is the speed. screen always been damn slow.
    otherwise they’re really very similar. i just enabled screen-like bindings and i feel like i’m using screen really.. just faster.. and some things like title detection work better

  • tmux is fantastic! I’m an Emacs user, and I’ve found that C-z is the most comfortable and unobtrustive escape for me.

  • Vince

    C-z is a terrible choice. Apparently you never use Berkeley
    job control. I use C-z *all the time* to suspend my current
    process, do something else, and then “fg” to resume. The
    problem is that most of the control keys are used by one
    application or another. I have been using screen on BSD and
    am about to try tmux. C-a has been a minor inconvenience,
    because of it being the emacs beginning of line command,
    although I am primarily a vim user. C-b is the emacs
    command to move the cursor back one character and the vi
    command to go scroll back a page. Although, there are
    alternatives, such as the arrow keys for those functions, so
    C-b probably would be less of an inconvenience for me than
    C-a has been.

    Perhaps an ALT key, such as M-s (s for screen controls),
    M-a, or M-b would be a good choice.

  • mark bill

    ctrl-P

    easy to press and AFAIK unassigned anywhere.

  • Vincent Stemen

    Nope. p and n are used extensively.
    They go to the previous and next line in both emacs
    and in normal mode in vi, they go forward and
    backward in the history in emacs editing mode of the
    shell, and, most importantly, they perform string
    completion in insert mode (similar to in bash
    and zsh) in vim for matching strings before or after
    the current cursor position.

  • Vincent Stemen

    Arghh! I specified ctrl with angle brackets and
    it stripped them out as tags.
    I meant C-p and C-n.

  • Vince: Like Ramkumar, I use C-z as my escape. I make heavy use of job control, but haven’t found that hitting ‘C-z z’ is particularly more inconvenient than a plain ‘C-z’. (Unlike C-a, which is flat-out awful if one is used to emacs-style navigation.)

  • Vedat

    I’ve also spent quite a bit of time trying to choose an unused and easily accessible escape key. My final choice is Ctrl-l. The only time I use it is when my screen is messed up, and I want to redraw it, but it doesn’t occur often enough, so pressing “ctrl-l l” is not a big problem for me.

  • Jim

    Second the use of C-z for prefix key (C-z z is easy to type) and I also use C-q and C-s at times (flow control is practically useless these days).

    Plus, if you’re using job control that much, you’re doing it wrong. That’s what screen/tmux is for!

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">