Skip to content

Lesson 5 of 9 · 20m

tmux: The Terminal Multiplexer

Sessions that survive disconnects, panes that split your view, and the muscle memory that makes tmux the best $0 upgrade to remote work.

tmux solves two problems: sessions that survive your connection dropping, and more terminal space than a single window gives. Both are table stakes for serious remote work.

The model

  • Server — the daemon; survives your ssh disconnect.
  • Session — a named workspace (tmux new -s work).
  • Window — a full-screen tab within a session.
  • Pane — a split inside a window.

Attach, do work, detach (Ctrl-b d), the session runs on the server. Reconnect days later: tmux attach -t work — everything still there, logs still scrolling.

The essentials

tmux new -s work           # new session
tmux ls                    # list sessions
tmux attach -t work        # reattach

Inside tmux, everything hangs off the prefix Ctrl-b:

  • Ctrl-b % — split vertically; Ctrl-b " — horizontally
  • Ctrl-b arrows — move between panes
  • Ctrl-b c — new window; Ctrl-b n/p — next/prev window
  • Ctrl-b [ — scroll mode (q to quit)

The workflow patterns

  • Dev: one window for the editor (or vim), one for the test runner, one for git — all in one ssh connection.
  • Long jobs: tmux new -s build then run the deploy — detach, go home, reattach tomorrow.
  • Shared session: two people tmux attach to the same session — the original pair-programming remote.

Field notes

  • tmux -CC (iTerm2 integration) makes tmux windows native terminal windows — the best of both worlds.
  • set -g mouse on in ~/.tmux.conf enables scroll/click for pane selection — the quality-of-life flag everyone adds.
  • Nested tmux (tmux inside tmux) works — the inner prefix is Ctrl-b b (send-prefix); you usually don't want it.