🪟
tmux cheat sheet
tmux keeps your terminal sessions running when your SSH connection drops. Every shortcut starts with the prefix, Ctrl-b by default: press it, release, then press the key.
Click any command to copy it.
Sessions
| Command | What it does |
|---|---|
tmux new -s name | Start a named session. |
tmux ls | List sessions. |
tmux attach -t name | Attach to a session (or 'tmux a' for the latest). |
Ctrl-b d | Detach from the session, leaving it running. |
Ctrl-b $ | Rename the session. |
tmux kill-session -t name | Destructive: Kill a session and everything running in it. |
Ctrl-b s | Choose a session from a list. |
Windows (tabs)
| Command | What it does |
|---|---|
Ctrl-b c | Create a new window. |
Ctrl-b n / Ctrl-b p | Next / previous window. |
Ctrl-b 0 ... 9 | Jump to window by number. |
Ctrl-b , | Rename the window. |
Ctrl-b w | Choose a window from a list. |
Ctrl-b & | Close the window (asks first). |
Panes (splits)
| Command | What it does |
|---|---|
Ctrl-b % | Split left/right. |
Ctrl-b " | Split top/bottom. |
Ctrl-b arrow keys | Move between panes. |
Ctrl-b z | Zoom a pane to full screen and back. |
Ctrl-b x | Close the pane (asks first). |
Ctrl-b { / Ctrl-b } | Swap the pane with the previous / next one. |
Ctrl-b Space | Cycle through pane layouts. |
Ctrl-b Alt-arrow | Resize the pane. |
Scrolling and copying
| Command | What it does |
|---|---|
Ctrl-b [ | Enter copy mode to scroll with arrows, PageUp and PageDown. |
q | Leave copy mode. |
Ctrl-b ] | Paste the tmux buffer. |
Ctrl-b ? | List all key bindings. |
Configuration
| Command | What it does |
|---|---|
set -g mouse on | In ~/.tmux.conf: enable mouse scrolling and pane selection. |
set -g history-limit 50000 | In ~/.tmux.conf: keep more scrollback. |
tmux source-file ~/.tmux.conf | Reload the configuration. |
Ctrl-b : | Open the tmux command prompt. |
Frequently asked questions
How do I keep a command running after I disconnect?
Start it inside tmux, detach with Ctrl-b d, then log out. Reattach later with tmux attach.
How do I scroll in tmux?
Press Ctrl-b [ to enter copy mode, then use the arrow keys or PageUp. Or enable set -g mouse on to scroll with the mouse wheel.