Tmux Cheat Sheet
A short cheat sheet of tmux shortcuts I keep forgetting, mostly written down for myself.
All shortcuts below start with the prefix key, which by default is Ctrl+b. So prefix + c means: press Ctrl+b, release, then press c.
Sessions
A session is a collection of windows. This is handy to group your work, e.g. one session per project.
| Shortcut | Description |
|---|---|
tmux new -s <name> | Create a new named session |
tmux attach -t <name> | Attach to an existing session |
tmux kill-session -t <name> | Kill a session |
tmux ls | List all sessions |
prefix + d | Detach from the current session |
Creating a session while already inside one
If you’re already inside a tmux session and want to start another one, avoid nesting tmux inside tmux (running tmux new -s ... directly), since that causes prefix-key conflicts. Instead, create the new session in the background and switch to it:
| Shortcut | Description |
|---|---|
tmux new-session -d -s <name> | Create a new session in the background, without attaching to it |
prefix + s | Show an interactive list of sessions to switch between |
tmux switch-client -t <name> | Switch directly to a session by name |
Windows
A window is like a tab in your terminal, it takes up the whole screen and can contain multiple panes.
| Shortcut | Description |
|---|---|
prefix + c | Create a new window |
prefix + , | Rename the current window |
prefix + n | Go to the next window |
prefix + p | Go to the previous window |
prefix + 0-9 | Go to window by number |
Panes
Panes let you split a window into multiple sections, so you can run several things side by side.
| Shortcut | Description |
|---|---|
prefix + % | Split pane vertically |
prefix + " | Split pane horizontally |
prefix + o | Switch to the next pane |
prefix + arrow key | Switch to the pane in that direction |
prefix + x | Close the current pane |
Copy mode
I don’t use this often, but it’s handy to know: copy mode lets you scroll back through the pane’s history and copy text.
| Shortcut | Description |
|---|---|
prefix + [ | Enter copy mode (use arrow keys or Page Up/Page Down to scroll) |
Space | Start a selection (in copy mode) |
Enter | Copy the selection and exit copy mode |
prefix + ] | Paste the last copied text |
q | Quit copy mode |
Configuration: starting index at 1
By default, tmux numbers windows and panes starting at 0, which doesn’t line up with the 1 key on my keyboard. I like to start counting at 1 instead. You can change this by creating (or editing) ~/.tmux.conf:
# Start window and pane numbering at 1
set -g base-index 1
setw -g pane-base-index 1
# Renumber windows automatically when one is closed
set -g renumber-windows on
If tmux is already running, reload the config without restarting your session:
tmux source-file ~/.tmux.conf
Or, from inside tmux itself: prefix + : and then type source-file ~/.tmux.conf.
That’s it, a small cheat sheet that covers most of what I use tmux for on a daily basis.