tmux Cheat Sheet
A terminal multiplexer: split panes, several windows, and sessions that keep running after you disconnect (great over SSH). Every shortcut starts with the prefix Ctrl + b, then the key. Written below as prefix + key.
On this page
Sessions #
| Command / key | Action |
|---|---|
| Start a new session | |
| New session called "work" | |
| List sessions | |
| / | Attach to the last / a named session |
| Kill a session | |
| Kill everything | |
prefix d | Detach (the session keeps running) |
prefix s | Pick a session from a list |
prefix $ | Rename the session |
prefix ( / prefix ) | Previous / next session |
Windows (tabs) #
| Key | Action |
|---|---|
prefix c | New window |
prefix , | Rename window |
prefix n / prefix p | Next / previous window |
prefix 0…9 | Go to window number |
prefix w | Pick from a list of all windows |
prefix & | Kill window |
Panes (splits) #
| Key | Action |
|---|---|
prefix % | Split left / right |
prefix " | Split top / bottom |
prefix ←/→/↑/↓ | Move to a pane |
prefix o | Next pane |
prefix z | Zoom the pane to full size (again to restore) |
prefix x | Kill the pane |
prefix q | Show pane numbers (press a number to jump) |
prefix { / prefix } | Swap pane left / right |
prefix Space | Cycle layouts |
prefix ! | Turn the pane into its own window |
prefix Ctrl + ←/→/↑/↓ | Resize the pane |
Copy Mode (scroll & copy) #
| Key | Action |
|---|---|
prefix [ | Enter copy mode (scroll with arrows / PgUp) |
q | Exit copy mode |
Ctrl + Space then move, Alt + w | Select and copy (default emacs keys) |
Space then move, Enter | Select and copy (with mode-keys vi) |
/ or ? | Search (vi keys) |
prefix ] | Paste |
Misc #
| Key | Action |
|---|---|
prefix ? | List all keybindings |
prefix : | Command prompt (for example :kill-pane) |
prefix t | Big clock |
prefix r | Reload the config (if you bound it, see below) |
Starter ~/.tmux.conf #
set -g mouse on # click panes, drag to resize, scroll
set -g base-index 1 # windows start at 1
setw -g pane-base-index 1
setw -g mode-keys vi # vi keys in copy mode
set -g history-limit 50000
# easier splits that open in the current folder
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# reload config
bind r source-file ~/.tmux.conf \; display "Reloaded"
# optional: use Ctrl+a as the prefix
# unbind C-b
# set -g prefix C-a
# bind C-a send-prefix
Apply with tmux source-file ~/.tmux.conf.
Tips #
- Typical SSH workflow:
ssh server→tmux a || tmux new→ work →prefix d→ log out. Your programs keep running. - With
mouse on, holdShiftwhile selecting to use your terminal's normal copy.
tmuxTerminal multiplexer: sessions, windows, panes. tmux [command] [options]
| Command / option | What it does |
|---|---|
tmux | New session |
new -s work | New named session (-d = start detached, -n = window name) |
ls | List sessions |
a / attach -t work | Attach to the last / a named session (-d detaches others) |
kill-session -t work | Kill a session (-a = all except the current one) |
kill-server | Kill everything |
rename-session -t old new | Rename a session |
new-window -n logs | New window |
split-window -h / -v | Split side by side / stacked |
send-keys -t work "npm run dev" Enter | Type into a session (scripts) |
source-file ~/.tmux.conf | Reload the config |
list-keys | All key bindings |
-f file | Use another config file |
-L name | Separate tmux server (socket name) |
-u | Force UTF-8 |
Nothing on this sheet matches “”.