Tools I use: tmux

Readers of this blog will know that I’m a big fan of GNU screen. While screen is a great tool, it hasn’t seen any major development or feature addition in quite some time. The code base is pretty old, there are some ancient bugs that still linger, and support for modern terminals (such as 256 colors by default) is not quite up to speed. I recently discovered byobu and was extremely happy with it — it completely overhauled my screen user experience. You can read all about byobu here.

I thought I had attained screen nirvana… until I found tmux (hat tip xed). So what exactly is tmux?

tmux is intended to be a modern, BSD-licensed alternative to programs such as GNU screen. Major features include:

  • A powerful, consistent, well-documented and easily scriptable command interface.
  • A window may be split horizontally and vertically into panes.
  • Panes can be freely moved and resized, or arranged into one of four preset layouts.
  • Support for UTF-8 and 256-colour terminals.
  • Copy and paste with multiple buffers.
  • Interactive menus to select windows, sessions or clients.
  • Change the current window by searching for text in the target.
  • Terminal locking, manually or after a timeout.
  • A clean, easily extended, BSD-licensed codebase, under active development.

And how is tmux better than screen? Thats question #1 in the FAQ:

tmux offers several advantages over screen:
- a clearly-defined client-server model: windows are independent entities which may be attached simultaneously to multiple sessions and viewed from multiple clients (terminals), as well as moved freely between sessions within the same tmux server;
- a consistent, well-documented command interface, with the same syntax whether used interactively, as a key binding, or from the shell;
- easily scriptable from the shell;
- multiple paste buffers;
- choice of vi or emacs key layouts;
- an option to limit the window size;
- a more usable status line syntax, with the ability to display the first line of output of a specific command;
- a cleaner, modern, easily extended, BSD-licensed codebase.
There are still a few features screen includes that tmux omits:
- builtin serial and telnet support; this is bloat and is unlikely to be added to tmux;
- wider platform support, for example IRIX and HP-UX, and for odd terminals.
I’ve been using tmux exclusively for the last couple of weeks and I really like it so far. For once, I can actually understand the configuration file :) But there are a few things that I miss from screen:
  • I found the screen way of scrolling in a buffer and copying text much easier to use than tmux’s. Unless I’m missing something, the only way to scroll a buffer in tmux and copy some text is by using vi-like keyboard commands. While this is doable, it is not always quick or convenient.
  • byobu made it really easy to add various status indicators. Wish I had something similar for tmux.

13 comments

  1. Nikhil

    Divx, thanks for the share. Really helpful.
    One problem though – I am using xoria256 for vim, but inside tmux, the background of the non text portion is black instead of grey. Tried to find a fix, but unsuccessful. Any suggestions?

  2. Xed

    Just to make this whole topic more interesting, my biggest annoyance with screen seems to be on the mend. Turns out that Ubuntu’s screen (at least) has vertical splits (yourescapekey->pipe). This could be related to byobu (I don’t fully understand what the heck that is). This screen in Ubuntu has it:
    screen 4.00.03jw4 (FAU) 2-May-06
    This screen in Gentoo does not:
    Screen version 4.00.03 (FAU) 23-Oct-06
    So go figure. I didn’t really want the hassle of switching, but I must say that tmux really did their best to ease that transition.

    Also, tmux cures screen’s most absurd problem: impossible to search google for it (reminds me of my browser named “links”).

    Time to give tmux a proper chance!

    • Gary

      > Also, tmux cures screen’s most absurd problem: impossible to search google for it

      Always google for “gnu screen”. That works fine.

  3. A B

    I’m not sure where you found the idea that you can’t scroll, copy or paste in tmux without using vi keys, tmux by default uses emacs key bindings, you have to explicitly configure it if you want vi keys (this is the opposite of screen which defaults to vi-like key bindings).

  4. Michael

    While I prefer the vi keybindings, tmux offers emacs key bindings as well. The option:

    set-window-option -g mode-keys emacs

    in ~/.tmux.conf will set it for all windows.

  5. A B

    Hmm, that’s weird. tmux only claims the mouse in copy mode if you have mouse-select-pane turned on.

    If you do, in most terminals you can use Shift to override tmux taking over the mouse in order to make selections.

Leave a Reply