(Last updated 2022.)

tmux is a terminal multiplexer, like screen. See tmux(1).

tmux has several modes: default terminal mode, command mode (prefix-:), and copy mode (prefix-[).

Start a new, named session with tmux new -s foo. Attach to an existing session with tmux attach -t foo. List existing sessions with tmux ls. Kill a session with tmux kill-session -t foo.

Reload the config file with :source-file ~/.tmux.conf.

The default command key bindings are:

C-b         Send the prefix key (C-b) through to the application.
C-o         Rotate the panes in the current window forwards.
C-z         Suspend the tmux client.
!           Break the current pane out of the window.
"           Split the current pane into two, top and bottom.
%           Split the current pane into two, left and right.
[SPACE]     Toggle vertical/horizonal pane split.
z           Un-split/Join/maximize/convert pane to a window.
#           List all paste buffers.
$           Rename the current session.
&           Kill the current window.
'           Prompt for a window index to select.
,           Rename the current window.
-           Delete the most recently copied buffer of text.
.           Prompt for an index to move the current window.
0 to 9      Select windows 0 to 9.
:           Enter the tmux command prompt.
;           Move to the previously active pane.
=           Choose which buffer to paste interactively from a list.
?           List all key bindings.
D           Choose a client to detach.
[           Enter copy mode to copy text or <b>view the scrollback history</b>.
]           Paste the most recently copied buffer of text.
c           Create a new window.
d           Detach the current client.
f           Prompt to search for text in open windows.
i           Display some information about the current window.
l           Move to the previously selected window.
n           Change to the next window.
o           Select the next pane in the current window.
p           Change to the previous window.
q           Briefly display pane indexes.
r           Force redraw of the attached client.
s           Select a new session for the attached client interactively.
L           Switch the attached client back to the last session.
t           Show the time.
w           Choose the current window interactively.
x           Kill the current pane.
{           Swap the current pane with the previous pane.
}           Swap the current pane with the next pane.
~           Show previous messages from tmux, if any.
Page Up     Enter copy mode and scroll one page up.
Up, Down
Left, Right
		   Change to the pane above, below, to the left, or to the right of the current pane.
M-1 to M-5  Arrange panes in one of the five preset layouts: even-horizontal, even-vertical,
		   main-horizontal, main-vertical, or tiled.
M-n         Move to the next window with a bell or activity marker.
M-o         Rotate the panes in the current window backwards.
M-p         Move to the previous window with a bell or activity marker.
C-Up, C-Down
C-Left, C-Right
		   Resize the current pane in steps of one cell.
M-Up, M-Down
M-Left, M-Right
		   Resize the current pane in steps of five cells.

tmux can be customized in ~/.tmux.conf, like:

set-option -g default-shell /usr/bin/zsh
set-option -g renumber-windows on
set -g prefix C-a
unbind C-b
bind-key C-a send-prefix
set-option -g base-index 1
set -g set-titles on
set -g set-titles-string "#h #W #T"
set -g status-bg "colour143"
set -g status-fg "black"
set -g pane-active-border-fg "colour204"
set -g escape-time 10
set -g history-limit 10000
set-window-option -g mode-keys vi
bind-key -n F1 select-window -t :1
bind-key -n F2 select-window -t :2
bind-key -n F3 select-window -t :3
bind-key -n F4 select-window -t :4
bind-key -n F5 select-window -t :5
bind-key -n F6 select-window -t :6
bind-key -n F7 select-window -t :7
bind-key -n F8 select-window -t :8
bind-key -n F9 select-window -t :9
bind-key -n F10 select-window -t :0

Things I forget most often:

prefix-[    Enter copy mode.
    Space   In copy mode, begin visual selection.
    Enter   With a visual selection, copy it.
    v       Toggle visual selection mode (and hit Space after to actually start selection).

:swap-window -s 2 -t 1    Swap window source 1 with window target 1.

prefix-?    List tmux key bindings