tmux Cheatsheet
Windows
Use this tmux reference while you build software engineering projects, review code, or refresh the syntax you reach for most.
Window Bindings
A window is a tab. Each window fills the client's screen and holds one or more panes.
| Keys | Action |
|---|---|
prefix c | Create a window |
prefix , | Rename this window |
prefix & | Kill this window (asks to confirm) |
prefix n / prefix p | Next / previous window |
prefix 0…9 | Select window by index |
prefix ' | Prompt for a window index |
prefix l | Last used window (toggle) |
prefix w | Interactive tree of sessions and windows |
prefix f | Find a window by name or content |
prefix . | Move this window to another index |
prefix M-n / prefix M-p | Next / previous window with activity |
Windows From the Command Line
tmux new-window # in the current session tmux new-window -n logs # named tmux new-window -c ~/src # with a starting directory tmux new-window -t work:5 # at a specific index tmux new-window -d -n build # create without switching to it tmux new-window 'tail -f app.log' # run a command in it tmux rename-window logs tmux kill-window -t logs tmux select-window -t 3 tmux move-window -t 1 # renumber this window tmux move-window -s work:2 -t dev:4 # move between sessions tmux swap-window -s 2 -t 4 tmux list-windows
Windows are addressed as session:window, and panes as session:window.pane. work:2.1 means session work, window 2, pane 1.
Naming and Numbering
set -g base-index 1 # windows start at 1, not 0 setw -g pane-base-index 1 # panes too set -g renumber-windows on # close a window, no gaps left behind setw -g automatic-rename on # name windows after the running program setw -g automatic-rename-format '#{b:pane_current_path}' set -g allow-rename off # stop programs from renaming your windows
base-index 1 is worth setting on day one: the 0 key is at the far end of the row, so a session that starts at 1 matches your fingers.
Activity and Alerts
setw -g monitor-activity on # flag a window when output appears setw -g monitor-bell on set -g visual-activity off # do not print a message, just flag it set -g visual-bell off set -g bell-action any setw -g monitor-silence 0 # flag after N seconds of no output
| Keys | Action |
|---|---|
prefix M-n | Next window with an alert |
prefix M-p | Previous window with an alert |
monitor-silence is the useful inverse: flag a window when a long build has stopped producing output, which usually means it finished.
Linking Windows
A window can appear in more than one session, sharing the same panes and processes.
tmux link-window -s work:2 -t dev:5 # same window in both sessions tmux unlink-window -t dev:5 # remove it from this session tmux move-window -s work:2 -t dev:5 # link then unlink, in one step
Killing a linked window in one session leaves it in the other. It is only destroyed when the last link goes away.
Window Targeting Quick Reference
| Target | Means |
|---|---|
-t 3 | Window index 3 in the current session |
-t name | The window whose name matches |
-t =name | Exact name match, no prefix matching |
-t work:3 | Window 3 of session work |
-t ! | The last window |
-t ^ / -t $ | First / last window |
-t + / -t - | Next / previous window |
-t @7 | A window by its unique id |