tmux Terminal Multiplexer Manual & Cheat Sheet
tmux is a terminal multiplexer that allows you to create, access, and control multiple terminal sessions from a single screen. It lets you detach from sessions and reattach to them later, keeping your processes running in the background.
Core Concepts
- Session: A collection of windows managed by
tmux. Keeps running even when detached. - Window: A single screen within a session (equivalent to tabs in a web browser).
- Pane: A rectangular division within a window running a separate pseudo-terminal.
Default Prefix Key:
Ctrl + b(written below asPrefix). To execute any in-session command, pressPrefix, release both keys, and then press the command key.
Session Management (Terminal Commands)
| Action | Command |
|---|---|
| Start new session | tmux |
| Start named session | tmux new -s <session-name> |
| List sessions | tmux ls (or tmux list-sessions) |
| Attach to last session | tmux a (or tmux attach) |
| Attach to named session | tmux a -t <session-name> |
| Kill named session | tmux kill-session -t <session-name> |
| Kill all sessions except current | tmux kill-session -a |
| Kill tmux server (all sessions) | tmux kill-server |
In-Session Shortcuts
Session Controls
| Shortcut | Action |
|---|---|
Prefix + d | Detach from current session |
Prefix + ( | Switch to previous session |
Prefix + ) | Switch to next session |
Prefix + s | Interactive session selector (tree view) |
Prefix + $ | Rename current session |
Window Controls (Tabs)
| Shortcut | Action |
|---|---|
Prefix + c | Create new window |
Prefix + , | Rename current window |
Prefix + w | Choose window from interactive list |
Prefix + n | Move to next window |
Prefix + p | Move to previous window |
Prefix + 0–9 | Select window by number |
Prefix + & | Kill current window |
Prefix + . | Move/re-number current window |
Pane Controls (Splits)
| Shortcut | Action |
|---|---|
Prefix + % | Split pane vertically (left / right) |
Prefix + " | Split pane horizontally (top / bottom) |
Prefix + Arrow Key | Move focus to adjacent pane |
Prefix + ; | Toggle to last active pane |
Prefix + o | Swap focus to next pane |
Prefix + z | Toggle pane zoom (fullscreen / restore) |
Prefix + x | Close/kill current pane |
Prefix + { | Swap current pane with previous pane |
Prefix + } | Swap current pane with next pane |
Prefix + Space | Toggle preset pane layouts |
Prefix + Ctrl + Arrow | Resize active pane in steps |
Prefix + q | Display pane numbers (type number to focus) |
Prefix + ! | Convert pane into its own window |
Navigation & Copy Mode
- Enter Copy Mode:
Prefix+[ - Move cursor using Arrow keys,
PageUp/PageDown, or Vim keys (h,j,k,l) if enabled. - Start Selection: Press
Space - Copy Selection: Press
Enter - Paste Copied Text:
Prefix+] - Exit Copy Mode:
qorEsc
Configuration (~/.tmux.conf)
Customise tmux settings by creating or editing ~/.tmux.conf.
Recommended Starter Configuration
# Enable mouse support (clickable panes, windows, scrolling)
set -g mouse on
# Use Vi keybindings in copy mode (scrollback navigation)
set -g mode-keys vi
# Vim-style copy & paste bindings in copy mode
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
# Set split pane shortcuts to more intuitive keys
bind \\ split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# Easy config reload shortcut
bind r source-file ~/.tmux.conf \; display "Config Reloaded!"
# Vim-style pane selection
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Enable 256-color support
set -g default-terminal "screen-256color"To reload configuration without restarting tmux, run:
tmux source ~/.tmux.conf