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.

20 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!

  • argv

    One important difference I’ve learned is that tmux cannot handle vt100 (cf. vt220). For the BSD I use, that appears to pose a problem if you want to run it on the /dev/console device (cf. /dev/tty01,02,…).

  • mr0

    Maybe C-a was chosen as a deliberately high collision default (emacs/readline/bash/…) thus encouraging the new user to configure for themselves. I like C-l enough to consider changing from C-g :)

  • acontrol

    The author explains why he chose control-b on the tmux webpage – the program was developed under screen.

    I haven’t decided yet what to use myself – some folks say b is too far from the control key, but on an azerty keyboard, it’s not THAT far off. On a qwertz keyboard, z is further; and yes, I am sometimes at machines where you have those keymaps.

    Which is another area where tmux is great – control-a [ and control-a ] are the screen bindings for the copy/paste bits… on many keymappings, such as .se/fi, the [ and ] keys require rediculous keypresses (alt, shift, magic-jump-thru-hoop, esc, :, w, q, compose, super, up, up, down, down, left, right, left, right, b, a, start, punch, Å for [) and thus the ability to bind these to, say, the Å key itself is a great thing.

    (Yes I know the US doesn’t have an Å key. You also don’t have the key between the Z and the left shift, or the key that would be where the left dogleg of the return key is. So using THOSE keys would be an option, if I didn’t occasionally run into keyboards from the US.)

  • landed on this page while googling tmux, as I wanted to compare it with screen. Nice info to start with. BTW, I ve been using screen for quite some time, as you guys said, C-a was annoying one if you’re an emacs user, however, you can always switch to a different command switch in screen with specifying “escape [switch-cmd]” in .screenrc.

  • noah

    How about C-s? Does anybody actually use XOFF and XON?

    I’m a Vim user and I use C-a in Vim (to increment the integer under the cursor). I also use C-a in its Emacs definition in Bash (Home).

  • Vincent Stemen

    I use C-s once in a while, but rarely. I think it would be a less conflicting choice than most of the other suggestions so far. However, it may not be as simple as just configuring tmux. I suspect the xterm may intercept it before being passed to tmux. I know I tested setting a key binding for C-s in vim but XOFF overrode it.

    Lately, under screen, I have been using C-` (Control – back tick) as the prefix command. That has been working pretty well. I don’t know of any conflicts.

    Another option might be a window key, such as win-a, in place of C-a. It seems most keyboards now days have the window key next to the left control key. I don’t think may applications use it and, being that it is for curses based windowing functions, it seems a fairly logical choice. Although, I use it quite a bit for custom bindings to launch windows, such as win-b to launch a browser and win-t to launch an xterm.

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="">