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.
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)
| Key | Action |
|---|---|
| d | Detach and leave everything running |
| s | Choose a session from a list |
| $ | Rename the session |
| ( ) | Previous / next session |
Windows
| Key | Action |
|---|---|
| c | Create a window |
| n / p | Next / previous window |
| 0 ... 9 | Jump to that window number |
| w | Pick a window from a list |
| , | Rename the window |
| & | Close the window |
Panes
| Key | Action |
|---|---|
| % | Split into left and right panes |
| " | Split into top and bottom panes |
| Arrow keys | Move to the pane in that direction |
| o | Cycle through panes |
| z | Zoom the pane (press again to restore) |
| x | Close the pane |
| { } | Swap the pane with the previous / next one |
| Space | Cycle through pane layouts |
| q | Show the pane numbers |
| Ctrl+arrow | Resize the pane (hold Ctrl) |
Copy mode
| Key | Action |
|---|---|
| [ | Enter copy mode (scroll with the arrows or Page Up) |
| q | Leave copy mode |
| / ? | Search forward / backward (in vi mode) |
| Space | Start selecting (in vi mode) |
| Enter | Copy 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.