Tip 79: Try a multiplexer

08 March 12. [link] PDF version

level: command-liner
purpose: so very much

Part of a series of tips on POSIX and C. Start from the tip intro page, or get 21st Century C, the book based on this series.

I always have two terminals open when coding: one with the code in an editor, and one for compiling and running the program (probably in a debugger). Working on an R package, I'll have a terminal with C side code, a terminal with the R side code, a compilation/run terminal, and because R is so undocumented a window with R's source code.

Deftly jumping among terminals has suddenly become incredibly important.

There are two terminal multiplexers to choose from, on either side of the great GNU|BSD rivarly: GNU Screen and tmux.

Not to take sides on the license thing, but tmux is more recently written and has learned from some of GNU Screen's mistakes. I like Screen's copy mode better. Maybe next year all that will be reversed.

Your package manager will probably install either or both of them.

Both work via a single command key. GNU Screen defaults to <ctrl>-A. Tmux defaults to <ctrl>-B, but the consensus seems to be that everybody remaps that to use <ctrl>-A instead, by adding

unbind C-b
set -g prefix C-a
bind a send-prefix

to .tmux_conf in their home directory. There are lots of other things that you can add to your configuration files. I'm not going to read you the manual here, just point out to you how really fabulous these things are so you're compelled to try them. When searching for tips and documentation, notice that GNU Screen is the name to type into your search engine, because Screen by itself will get you nowhere.

Once you've done that, <ctrl>-A <ctrl>-A jumps between two windows, and you can RTFM for the <ctrl>-A (otherkey) combinations that will let you step forward or backward in the window list, or display the full list of windows so you can just pick from the list.

So both of these guys solve the multi-window problem. But they do so very much more:

OK, how's that for a sell? These multiplexers really take that last step from making the terminal a place to work to being a fun place to work.


[Previous entry: "Tip 78: Use mmap for gigantic data sets"]
[Next entry: "Tip 80: Send in parameters fast"]