Skip to content
abdallahmekky

CHEAT SHEET

tmux cheat sheet

Sessions, windows and panes that survive a dropped connection. Every shortcut starts with the prefix: Ctrl+b, then the key.

All cheat sheets

Sessions

tmux                        # start a new sessiontmux new -s lab             # start a named sessiontmux ls                     # list sessionstmux attach -t lab          # reattach to a sessiontmux a                      # attach to the last sessiontmux rename-session -t old new    # rename a sessiontmux kill-session -t lab    # close one sessiontmux kill-server            # close everything

Session keys (after Ctrl+b)

KeyAction
dDetach and leave everything running
sChoose a session from a list
$Rename the session
( )Previous / next session

Windows

KeyAction
cCreate a window
n / pNext / previous window
0 ... 9Jump to that window number
wPick a window from a list
,Rename the window
&Close the window

Panes

KeyAction
%Split into left and right panes
"Split into top and bottom panes
Arrow keysMove to the pane in that direction
oCycle through panes
zZoom the pane (press again to restore)
xClose the pane
{ }Swap the pane with the previous / next one
SpaceCycle through pane layouts
qShow the pane numbers
Ctrl+arrowResize the pane (hold Ctrl)

Copy mode

KeyAction
[Enter copy mode (scroll with the arrows or Page Up)
qLeave copy mode
/ ?Search forward / backward (in vi mode)
SpaceStart selecting (in vi mode)
EnterCopy the selection (in vi mode)
]Paste the copied text

A starter ~/.tmux.conf

set -g mouse on                    # use the mouse for panes and scrollingset -g base-index 1                # number windows from 1setw -g pane-base-index 1          # number panes from 1setw -g mode-keys vi               # vi keys in copy modeset -g history-limit 50000         # a long scrollbackbind r source-file ~/.tmux.conf \; display "reloaded"    # prefix + r reloads the file

Reload the file from a terminal with: tmux source-file ~/.tmux.conf

More cheat sheets

Questions

What is the default tmux prefix key?

Ctrl+b. Press Ctrl+b, release, then press the next key. For example Ctrl+b then d detaches from the session.

How do I split the screen in tmux?

Press Ctrl+b then % to split into left and right panes, or Ctrl+b then " to split into top and bottom panes.

How do I keep a command running after I disconnect?

Run it inside tmux, detach with Ctrl+b then d, and reattach later with tmux attach.

How do I scroll in tmux?

Press Ctrl+b then [ to enter copy mode, scroll with the arrow keys or Page Up, and press q to leave.