tmux▍

One terminal, split into panes and grouped into windows — and it all keeps running after you close the lid. Every command below is two beats: press the prefix, let go, press the key.

prefix is C-b C-b means Ctrl and b M-b means Alt and b
~/api
$ nvim server.go
  12 func main() {
  13   log.Fatal(srv.Run())
  14 }
$ go test ./...
ok  api/store  0.42s
ok  api/http   1.10s
$ tail -f app.log
14:31 GET /health 200
14:32 GET /orders 200
[dev] 0:api* 1:logs 2:ssh "sol" 14:32
C-b%

0 How it fits together

tmux server — started by your first tmux command, outlives every terminal you close
session "dev" — attached
window 0: api
pane 0
pane 1
pane 2
window 1: logs
pane 0
session "notes" — detached, still running
window 0
pane 0

The loop that matters: tmux a → work → C-b d → walk away → tmux a. Nothing you started ever had to stop.

1 The keyboard, mapped

Every binding lives on one key, and the keys cluster by job. Tap one to see what it does — shifted symbols sit in the corner, tinted by their own job.

sessions windows panes scroll & copy asking tmux
- e y u \ a g h j k v b

Blank keys are yours to bind. The four colours are the four things tmux manages.

What the pane keys draw

The symbols aren't arbitrary — most of them are a picture of the result.

C-b%

The slash inside % is the divider, standing up.

C-b"

Both marks hang from the top, like a shelf across the window.

C-b←↓↑→

Focus follows the arrow. Nothing moves but you.

C-bz

Zoom fills the window. The others are hidden, not gone — press it again.

C-bx

Close the pane you're in. The rest reflow to fill the gap.

C-b!

The pane leaves and becomes a window of its own.

AB BA
C-b{}

The braces push the pane one seat earlier or later.

C-bC-←M-←

Ctrl nudges by one cell, Alt by five. Keep tapping — the prefix sticks.

running
C-bd

Your terminal lets go. The session carries on without you.

The five layouts

C-b Space cycles through them; the numbered keys jump straight there.

M-1even columns
M-2even rows
M-3main on top
M-4main on the left
M-5tiled

The letters are just the words

  • ccreate a window
  • ddetach
  • ssessions
  • wwindows
  • ffind a window
  • nnext window
  • pprevious window
  • llast window
  • othe other pane
  • zzoom
  • xexit a pane
  • qquick pane numbers
  • tthe time
  • mmark a pane
  • iwindow info
  • rredraw the screen

2 Start and come back from the shell

tmux Start a session with no name.
tmux new -s dev Start a session called dev.
tmux new -A -s dev Attach to dev, or create it if it isn't there.The one to make an alias of — it never errors either way.
tmux ls List every session and how many windows it has.
tmux a Attach to the most recent session.
tmux a -t dev Attach to a session by name.
tmux a -d -t dev Attach here and kick other clients off.Fixes the squashed layout when an old laptop is still attached.
tmux new -d -s build 'make all' Run something in a session without attaching.
tmux kill-session -t dev End one session.
tmux kill-session -a End every session except the current one.
tmux kill-server End all of it, server included.
tmux source ~/.tmux.conf Reload your config from outside tmux.

Click any command to copy it.

3 Sessions inside tmux

C-bd
Detach. Everything keeps running.The single most useful key in tmux.
C-bs
Open the session picker and jump between sessions.
C-b$
Rename this session.
C-b()
Previous / next session, no picker.
C-bD
Pick which attached client to detach.
C-bC-b
Send the prefix through to a tmux running inside this one.For when you're in tmux over SSH, inside tmux.

4 Windows the tabs

C-bc
New window.
C-b,
Rename this window.Named windows are how the status line stops being noise.
C-b0…9
Jump straight to a window by number.
C-b'
Type a window number — for 10 and up.
C-bnp
Next / previous window.
C-bl
Back to the window you were just in.
C-bw
Browse every window in every session, with previews.
C-bf
Find a window by text on its screen.
C-b.
Move this window to a different number.
C-b&
Close this window. It asks first.

5 Panes the splits

C-b%
Split into left and right.The slash inside % is the divider, standing up.
C-b"
Split into top and bottom.Both marks hang from the top, like a shelf across the window.
C-b←↓↑→
Move focus in that direction.
C-bo;
Cycle to the next pane / flip back to the last one.
C-bq
Flash the pane numbers — press one to jump there.
C-bz
Blow this pane up to the whole window; press again to put it back.Nothing is lost while zoomed — the others are just hidden.
C-bx
Close this pane. It asks first.
C-bSpace
Cycle through the built-in layouts.
C-bM-1…M-5
Jump to a layout: even columns, even rows, main pane on top, main pane on the left, tiled.
C-b{}
Swap this pane with the one before / after it.
C-bC-o
Rotate every pane around the layout.
C-b!
Pop this pane out into a window of its own.
C-bC-←
Resize by one cell — keep tapping the arrow, the prefix sticks.
C-bM-←
Resize by five cells at a time.
C-bt
A giant clock in this pane. Any key dismisses it.

With mouse on you can also click a pane to focus it and drag the borders to resize.

6 Scroll back and copy

C-b[
Enter copy mode. This is how you scroll up.If your keyboard scroll does nothing, this is why.
q
Leave copy mode.
C-uC-d
Half a screen up / down. Arrows move by a line.
gG
Top of the scrollback / back to the bottom.
/ ? n
Search forward, search back, repeat.Where did that stack trace go — this, not your mouse.
SpaceEnter
Start the selection, then copy it and exit.
C-SpaceM-w
Same two steps if you haven't switched to vi keys.
C-b]
Paste what you copied.
C-b=
Pick from everything you've copied, not just the last one.

The vi keys here need setw -g mode-keys vi. tmux's buffers are its own — a clipboard tool like pbcopy or xclip is what gets text out to the rest of your machine.

7 Ask tmux itself

C-b?
Every binding, live and correct for your config.It opens in copy mode, so / searches it and q quits.
C-b:
Command prompt. Everything below goes here.
C-b~
Recent tmux messages, for when one flashed by.
:setw synchronize-panes Type into every pane at once. Run it again to stop.
:join-pane -s 3 Pull window 3 in as a pane here.
:break-pane Push this pane back out into its own window.
:swap-window -t 1 Trade places with window 1.
:resize-pane -y 20 Make this pane exactly 20 rows tall.
:capture-pane -S -5000 ; save-buffer out.txt Dump 5000 lines of scrollback to a file.
:pipe-pane -o 'cat >> pane.log' Keep logging this pane to a file until you run it again.

8 A config worth having ~/.tmux.conf

# the prefix your thumb can actually reach
set -g prefix C-a
unbind C-b
bind C-a send-prefix

set -g mouse on            # click, drag borders, scroll
set -g base-index 1        # windows start at 1, like the keyboard
setw -g pane-base-index 1
set -g renumber-windows on # no gaps after closing one
set -g history-limit 50000
set -sg escape-time 10      # stop Esc lagging in vim
setw -g mode-keys vi

# splits you can see in the key, opening where you already are
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %

# move between panes like vim (drops prefix-l for last window)
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# select and yank like vim
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi y send -X copy-selection-and-cancel

# reload without leaving
bind r source-file ~/.tmux.conf \; display "config reloaded"
Then C-b :source ~/.tmux.conf

Nothing matches . Try split, detach, copy or resize.

[tmux]