tmux cheatsheet
Searchable reference of tmux sessions, windows, panes, copy mode, key bindings and config snippets.
Default prefix: press Ctrl-b, release, then the key. Commands starting with : go at the Ctrl-b : prompt or after tmux in a shell.
129 of 129 entries
| Section | Keys or command | Description |
|---|---|---|
| Sessions | tmux | Start a new session. |
| Sessions | tmux new -s <name> | Start a new session with a name. |
| Sessions | tmux new -A -s <name> | Attach to a session, creating it first if it does not exist. |
| Sessions | tmux new -d -s <name> "<command>" | Start a detached session running a command. |
| Sessions | tmux ls | List sessions. |
| Sessions | tmux attach | Attach to the most recently used session (short: tmux a). |
| Sessions | tmux attach -t <name> | Attach to a named session. |
| Sessions | tmux attach -d -t <name> | Attach and detach every other client, so the window fits your terminal. |
| Sessions | tmux kill-session -t <name> | End a session and everything in it. |
| Sessions | tmux kill-server | End every session and stop the server. |
| Sessions | tmux rename-session -t <old> <new> | Rename a session. |
| Sessions | Ctrl-b d | Detach from the session; it keeps running. |
| Sessions | Ctrl-b D | Choose a client to detach. |
| Sessions | Ctrl-b s | Choose a session from a tree (also shows windows). |
| Sessions | Ctrl-b $ | Rename the current session. |
| Sessions | Ctrl-b ( Ctrl-b ) | Switch to the previous or next session. |
| Sessions | Ctrl-b L | Switch back to the last session. |
| Windows | Ctrl-b c | Create a new window. |
| Windows | Ctrl-b , | Rename the current window. |
| Windows | Ctrl-b & | Kill the current window (asks for confirmation). |
| Windows | Ctrl-b n Ctrl-b p | Next or previous window. |
| Windows | Ctrl-b 0 … 9 | Select window 0 to 9. |
| Windows | Ctrl-b ' | Prompt for a window index to select. |
| Windows | Ctrl-b l | Toggle to the last active window. |
| Windows | Ctrl-b w | Choose a window from a tree with previews. |
| Windows | Ctrl-b f | Find a window by name or visible text. |
| Windows | Ctrl-b . | Move the window to another index. |
| Windows | Ctrl-b i | Show information about the current window. |
| Windows | :new-window -n <name> "<command>" | Open a named window running a command. |
| Windows | :swap-window -t -1 | Swap the current window with the previous one, moving it one position left. |
| Windows | :move-window -r | Renumber windows to close gaps. |
| Windows | :setw monitor-activity on | Highlight the window in the status bar when it has new output. |
| Panes | Ctrl-b % | Split the pane left and right (side by side). |
| Panes | Ctrl-b " | Split the pane top and bottom (stacked). |
| Panes | Ctrl-b ← ↑ → ↓ | Move to the pane in that direction. |
| Panes | Ctrl-b o | Move to the next pane. |
| Panes | Ctrl-b ; | Toggle to the last active pane. |
| Panes | Ctrl-b q | Show pane numbers; press a number to jump to that pane. |
| Panes | Ctrl-b z | Zoom the pane to the full window, or restore it. |
| Panes | Ctrl-b x | Kill the current pane (asks for confirmation). |
| Panes | Ctrl-b ! | Break the pane out into a new window. |
| Panes | Ctrl-b { Ctrl-b } | Swap the pane with the previous or next one. |
| Panes | Ctrl-b Ctrl-o | Rotate the panes in the window. |
| Panes | Ctrl-b Space | Cycle through the preset layouts. |
| Panes | Ctrl-b Alt-1 … Alt-5 | Preset layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, tiled. |
| Panes | Ctrl-b Ctrl-←↑→↓ | Resize the pane by one cell. |
| Panes | Ctrl-b Alt-←↑→↓ | Resize the pane by five cells. |
| Panes | Ctrl-b m | Mark the pane (Ctrl-b M clears the mark); join-pane and swap-pane use it. |
| Panes | :resize-pane -D 10 | Resize by a number of cells: -U, -D, -L or -R. |
| Panes | :join-pane -s <window> | Move a pane from another window into this one. |
| Panes | :select-layout tiled | Apply a layout by name. |
| Panes | :setw synchronize-panes on | Type into every pane of the window at once (off to stop). |
| Panes | :split-window -h -c "#{pane_current_path}" | Split side by side, starting in the current pane’s directory. |
| Panes | :respawn-pane -k | Restart the command running in the pane. |
| Panes | :pipe-pane -o "cat >> ~/tmux.log" | Toggle logging the pane output to a file. |
| Copy & paste | Ctrl-b [ | Enter copy mode to scroll back and select text. |
| Copy & paste | Ctrl-b PgUp | Enter copy mode and scroll one page up. |
| Copy & paste | Ctrl-b ] | Paste the most recent buffer. |
| Copy & paste | Ctrl-b = | Choose a buffer to paste from a list. |
| Copy & paste | Ctrl-b # | List paste buffers. |
| Copy & paste | Ctrl-b - | Delete the most recent buffer. |
| Copy & paste | tmux show-buffer | Print the most recent buffer. |
| Copy & paste | tmux save-buffer <file> | Write the most recent buffer to a file. |
| Copy & paste | tmux capture-pane -p -S - > <file> | Save the full scrollback of the current pane to a file. |
| Copy & paste | Mouse drag | With mouse on, select text to copy it; hold Shift (Option in some terminals) for the terminal’s own selection. |
| Copy mode (vi keys) | q | Leave copy mode. |
| Copy mode (vi keys) | h j k l | Move left, down, up, right. |
| Copy mode (vi keys) | w b e | Next word, previous word, end of word. |
| Copy mode (vi keys) | 0 ^ $ | Start of line, first non-blank, end of line. |
| Copy mode (vi keys) | H M L | Top, middle or bottom of the visible screen. |
| Copy mode (vi keys) | Ctrl-u Ctrl-d | Half a page up or down. |
| Copy mode (vi keys) | Ctrl-b Ctrl-f | A full page up or down. |
| Copy mode (vi keys) | g G | Top or bottom of the scrollback history. |
| Copy mode (vi keys) | f F t T | Jump to a character on the line; ; and , repeat. |
| Copy mode (vi keys) | / ? | Search down or up. |
| Copy mode (vi keys) | n N | Next or previous match. |
| Copy mode (vi keys) | Space | Start a selection. |
| Copy mode (vi keys) | V | Select whole lines. |
| Copy mode (vi keys) | v | Toggle rectangle (block) selection. |
| Copy mode (vi keys) | o | Move to the other end of the selection. |
| Copy mode (vi keys) | Enter | Copy the selection to a buffer and leave copy mode. |
| Copy mode (vi keys) | Escape | Clear the selection. |
| Copy mode (emacs keys) | q Escape | Leave copy mode. |
| Copy mode (emacs keys) | Ctrl-f Ctrl-b Ctrl-n Ctrl-p | Move right, left, down, up (arrow keys work too). |
| Copy mode (emacs keys) | Alt-f Alt-b | Next or previous word. |
| Copy mode (emacs keys) | Ctrl-a Ctrl-e | Start or end of the line. |
| Copy mode (emacs keys) | Alt-v Ctrl-v | A page up or down. |
| Copy mode (emacs keys) | Alt-< Alt-> | Top or bottom of the scrollback history. |
| Copy mode (emacs keys) | Ctrl-s Ctrl-r | Search down or up; n and N repeat. |
| Copy mode (emacs keys) | Ctrl-Space | Start a selection. |
| Copy mode (emacs keys) | R | Toggle rectangle (block) selection. |
| Copy mode (emacs keys) | Alt-w | Copy the selection to a buffer and leave copy mode. |
| Copy mode (emacs keys) | Ctrl-g | Clear the selection. |
| Command line & scripting | Ctrl-b : | Open the command prompt. |
| Command line & scripting | Ctrl-b ? | List every key binding. |
| Command line & scripting | Ctrl-b ~ | Show previous tmux messages. |
| Command line & scripting | Ctrl-b t | Show a big clock in the pane. |
| Command line & scripting | Ctrl-b r | Redraw the client, e.g. after garbled output. |
| Command line & scripting | Ctrl-b Ctrl-z | Suspend the tmux client. |
| Command line & scripting | tmux source-file ~/.tmux.conf | Reload the configuration in a running server. |
| Command line & scripting | tmux send-keys -t <target> "make test" Enter | Type a command into another pane. |
| Command line & scripting | -t <session>:<window>.<pane> | Target syntax for most commands, e.g. -t work:2.1. |
| Command line & scripting | tmux display -p "#{session_name}" | Print a format variable, e.g. the session name. |
| Command line & scripting | tmux show-options -g | Show global options (-w for window options). |
| Command line & scripting | tmux list-keys -T copy-mode-vi | List the bindings of one key table. |
| Command line & scripting | tmux has-session -t <name> | Exit status 0 if the session exists; useful in scripts. |
| Command line & scripting | tmux -V | Print the tmux version. |
| Config | ~/.tmux.conf | Config file; tmux 3.1+ also reads ~/.config/tmux/tmux.conf. |
| Config | set -g prefix C-a | Use Ctrl-a as the prefix (add unbind C-b and bind C-a send-prefix). |
| Config | bind C-a send-prefix | Press the prefix twice to send it to the program inside. |
| Config | set -g mouse on | Click to select panes and windows, drag borders, scroll with the wheel. |
| Config | set -g base-index 1 | Number windows from 1 instead of 0. |
| Config | setw -g pane-base-index 1 | Number panes from 1. |
| Config | set -g renumber-windows on | Renumber windows when one is closed. |
| Config | set -g history-limit 50000 | Keep more scrollback lines per pane. |
| Config | set -sg escape-time 10 | Shorter Escape delay, so Vim inside tmux reacts quickly. |
| Config | setw -g mode-keys vi | Use vi keys in copy mode (the default is emacs unless $EDITOR mentions vi). |
| Config | set -g default-terminal "tmux-256color" | Advertise 256 colours to programs inside tmux. |
| Config | set -as terminal-features ",xterm-256color:RGB" | Enable true colour for an outer terminal (tmux 3.2+). |
| Config | set -g set-clipboard on | Copy to the system clipboard through the terminal (OSC 52). |
| Config | set -g focus-events on | Pass focus events to programs such as Vim. |
| Config | bind r source-file ~/.tmux.conf \; display "Reloaded" | Ctrl-b r reloads the config and confirms. |
| Config | bind | split-window -h -c "#{pane_current_path}" | Ctrl-b | splits side by side in the same directory. |
| Config | bind - split-window -v -c "#{pane_current_path}" | Ctrl-b - splits stacked in the same directory. |
| Config | bind -r h select-pane -L | Repeatable binding: press h several times after one prefix. |
| Config | bind -n M-Left select-pane -L | Binding without the prefix: Alt-← moves to the left pane. |
| Config | bind -T copy-mode-vi v send -X begin-selection | Vim-like v to start a selection in copy mode. |
| Config | bind -T copy-mode-vi y send -X copy-selection-and-cancel | Vim-like y to copy and leave copy mode. |
| Config | set -g status-position top | Move the status bar to the top. |