murkshelf

tmux: the five commands that cover 95% of usage

I resisted tmux for years because every cheat sheet starts with forty key bindings. In practice five cover almost everything:

tmux new -s work        # start a named session
Ctrl-b d                # detach (everything keeps running)
tmux attach -t work     # come back later
Ctrl-b %                # split left/right
Ctrl-b "                # split top/bottom

Everything else is bonus. The point of those five: your session survives a dropped SSH connection, a closed terminal window, or a laptop sleep. Start the session on the machine where the work runs, detach, reattach from anywhere.

Moving around

Copy mode

Ctrl-b [ enters copy mode — now you can scroll with arrows or PgUp/PgDn, exactly like a regular editor. q exits. This is the answer to “how do I scroll up in tmux”, which is the question that makes everyone hate tmux for the first week.

To copy: in copy mode, Space starts selection, Enter copies and exits. Ctrl-b ] pastes.

Sessions from the shell

tmux ls                  # list sessions
tmux kill-session -t old # kill one
tmux kill-server         # nuke everything

Mouse support

One line in ~/.tmux.conf makes pane borders clickable and scroll wheel work as expected:

set -g mouse on

Purists will say learn the bindings; pragmatists will turn the mouse on at 9am and turn it off before anyone sees. I keep it on.