Tmux command cheat sheet
tmux Sessions
- Start a new session:
tmuxortmux newortmux new-session - Start a new session with a specific name:
tmux new -s [session_name] - Attach to the last active session:
tmux attachortmux a - Attach to a session with a specific name:
tmux attach -t [session_name]ortmux at [session_name] - Disconnect from a session, but keep it running:
tmux detachorCTRL+bthend - List all active sessions:
tmux list-sessionsortmux lsorCTRL+bthens - Switch to a different session:
tmux switch -t [session_name] - Move to the previous session:
CTRL+bthen( - Move to the next session:
CTRL+bthen) - Rename an existing session:
tmux rename-session -t [old_name] [new_name]orCTRL+bthen$ - Terminate all sessions but the current one:
tmux kill-session -a - Terminate a specific session:
tmux kill-session -t [session_name]
tmux Windows
- Create a new window:
tmux new-windoworCTRL+bthenc - Create a new window with a specific name:
tmux new-window -n [window_name] - Switch to the previous window:
tmux previous-windoworCTRL+bthenp - Switch to the next window:
tmux next-windoworCTRL+bthenn - Go to a specific window number:
CTRL+bthen[number] - Rename the current window:
tmux rename-window [new_name]orCTRL+bthen, - Kill the current window:
tmux kill-windoworCTRL+bthen& - List all windows:
tmux list-windowsorCTRL+bthenw - Link a window to another session:
tmux link-window -s [source_session]:[source_window] -t [target_session] - Unlink a window:
tmux unlink-window -t [session]:[window]
tmux Panes
- Split the pane horizontally:
tmux split-window -horCTRL+bthen" - Split the pane vertically:
tmux split-window -vorCTRL+bthen% - Navigate between panes:
tmux select-pane -t [pane_number]orCTRL+bthen[arrow key] - Navigate to the next pane:
CTRL+btheno - Kill the current pane:
tmux kill-paneorCTRL+bthenx - Swap current pane with the previous one:
CTRL+bthen{ - Swap current pane with the next one:
CTRL+bthen} - Zoom in on the current pane:
tmux resize-pane -ZorCTRL+bthenz - Show pane numbers:
CTRL+bthenq
Pane Resizing
- Resize pane left (1 cell):
CTRL+bthenCTRL+Left - Resize pane right (1 cell):
CTRL+bthenCTRL+Right - Resize pane up (1 cell):
CTRL+bthenCTRL+Up - Resize pane down (1 cell):
CTRL+bthenCTRL+Down - Resize pane left (5 cells):
CTRL+bthenALT+Left - Resize pane right (5 cells):
CTRL+bthenALT+Right - Resize pane up (5 cells):
CTRL+bthenALT+Up - Resize pane down (5 cells):
CTRL+bthenALT+Down
tmux Copy Mode
- Enter copy mode:
tmux copy-modeorCTRL+bthen[ - Quit copy mode:
q - Start selection:
Spacebar - Clear selection:
Esc - Copy selection:
Enter - Paste contents of buffer_0:
CTRL+bthen] - Move the cursor left:
h - Move the cursor down:
j - Move the cursor up:
k - Move the cursor right:
l - Move the cursor forward one word at a time:
W - Move the cursor backward one word at a time:
b - Go to top line:
g - Go to bottom line:
G - Search forward:
/ - Search backward:
? - Previous keyword occurrence:
N - Next keyword occurrence:
n - Use vi keys in buffer:
setw -g mode-keys vi - Show all buffers:
list-buffers - Copy entire visible contents of pane to a buffer:
capture-pane - Show all buffers and paste selected:
choose-buffer
tmux Miscellaneous
- Detach and keep the session running:
tmux detachorCTRL+bthend - Show a list of all key bindings:
CTRL+bthen? - Command mode:
CTRL+bthen: - Reload configuration file:
tmux source-file ~/.tmux.conforCTRL+bthenr - Disconnect all other clients:
tmux detach-client -a - Force tmux to assume 256 colors:
tmux -2 - Send the prefix key to the current pane:
CTRL+bthenb - List all commands:
list-commands
Step-by-Step Examples
Example 1: Basic Multi-Pane Development Setup
- Start new session:
tmux new -s dev - Split horizontally for code editor:
CTRL+bthen" - Move to bottom pane:
CTRL+bthenDown Arrow - Split vertically for terminal and logs:
CTRL+bthen% - Navigate between panes:
CTRL+bthen arrow keys - Zoom into editor pane:
CTRL+bthenUp Arrow→CTRL+bthenz
Example 2: Resizing Panes for Better Layout
- Create horizontal split:
CTRL+bthen" - Top pane too small? Make it bigger:
CTRL+bthenCTRL+Down(repeat as needed) - Bottom pane now too big? Make it smaller:
CTRL+bthenCTRL+Up - For faster resizing:
CTRL+bthenALT+Down(resizes by 5 cells)
Example 3: Managing Multiple Projects
- Create first project session:
tmux new -s project1 - Work on project1, then detach:
CTRL+bthend - Create second project session:
tmux new -s project2 - Switch between projects:
tmux attach -t project1orCTRL+bthens - List all sessions:
tmux ls
Example 4: Copy Mode Workflow
- Enter copy mode:
CTRL+bthen[ - Navigate to text you want: arrow keys or
h/j/k/l - Start selection:
Spacebar - Extend selection: arrow keys
- Copy selection:
Enter - Move to different pane:
CTRL+bthen arrow key - Paste:
CTRL+bthen]
Example 5: Window and Pane Navigation
- Create new window:
CTRL+bthenc - Split into panes:
CTRL+bthen"→CTRL+bthen% - Show pane numbers:
CTRL+bthenq→ press2to jump to pane 2 - Switch windows:
CTRL+bthen1(for window 1) - Go back to previous window:
CTRL+bthenp
Example 6: Advanced Pane Management
- Create 4-pane layout:
- Start:
CTRL+bthen" - Top pane:
CTRL+bthen% - Bottom pane:
CTRL+bthenDown Arrow→CTRL+bthen%
- Start:
- Resize panes for code/terminal/logs/monitoring:
- Make code pane (top-left) larger:
CTRL+bthenCTRL+Right(repeat) - Make logs pane (bottom-right) taller:
CTRL+bthenCTRL+Up
- Make code pane (top-left) larger:
- Swap panes if needed:
CTRL+bthen{or}# Tmux Command Cheat Sheet
tmux Sessions
- Start a new session:
tmuxortmux newortmux new-session - Start a new session with a specific name:
tmux new -s [session_name] - Attach to the last active session:
tmux attachortmux a - Attach to a session with a specific name:
tmux attach -t [session_name]ortmux at [session_name] - Disconnect from a session, but keep it running:
tmux detachorCTRL+bthend - List all active sessions:
tmux list-sessionsortmux lsorCTRL+bthens - Switch to a different session:
tmux switch -t [session_name] - Move to the previous session:
CTRL+bthen( - Move to the next session:
CTRL+bthen) - Rename an existing session:
tmux rename-session -t [old_name] [new_name]orCTRL+bthen$ - Terminate all sessions but the current one:
tmux kill-session -a - Terminate a specific session:
tmux kill-session -t [session_name]
tmux Windows
- Create a new window:
tmux new-windoworCTRL+bthenc - Create a new window with a specific name:
tmux new-window -n [window_name] - Switch to the previous window:
tmux previous-windoworCTRL+bthenp - Switch to the next window:
tmux next-windoworCTRL+bthenn - Go to a specific window number:
CTRL+bthen[number] - Rename the current window:
tmux rename-window [new_name]orCTRL+bthen, - Kill the current window:
tmux kill-windoworCTRL+bthen& - List all windows:
tmux list-windowsorCTRL+bthenw - Link a window to another session:
tmux link-window -s [source_session]:[source_window] -t [target_session] - Unlink a window:
tmux unlink-window -t [session]:[window]
tmux Panes
- Split the pane horizontally:
tmux split-window -horCTRL+bthen" - Split the pane vertically:
tmux split-window -vorCTRL+bthen% - Navigate between panes:
tmux select-pane -t [pane_number]orCTRL+bthen[arrow key] - Navigate to the next pane:
CTRL+btheno - Kill the current pane:
tmux kill-paneorCTRL+bthenx - Swap current pane with the previous one:
CTRL+bthen{ - Swap current pane with the next one:
CTRL+bthen} - Zoom in on the current pane:
tmux resize-pane -ZorCTRL+bthenz - Show pane numbers:
CTRL+bthenq
Pane Resizing
- Resize pane left (1 cell):
CTRL+bthenCTRL+Left - Resize pane right (1 cell):
CTRL+bthenCTRL+Right - Resize pane up (1 cell):
CTRL+bthenCTRL+Up - Resize pane down (1 cell):
CTRL+bthenCTRL+Down - Resize pane left (5 cells):
CTRL+bthenALT+Left - Resize pane right (5 cells):
CTRL+bthenALT+Right - Resize pane up (5 cells):
CTRL+bthenALT+Up - Resize pane down (5 cells):
CTRL+bthenALT+Down
tmux Copy Mode
- Enter copy mode:
tmux copy-modeorCTRL+bthen[ - Quit copy mode:
q - Start selection:
Spacebar - Clear selection:
Esc - Copy selection:
Enter - Paste contents of buffer_0:
CTRL+bthen] - Move the cursor left:
h - Move the cursor down:
j - Move the cursor up:
k - Move the cursor right:
l - Move the cursor forward one word at a time:
W - Move the cursor backward one word at a time:
b - Go to top line:
g - Go to bottom line:
G - Search forward:
/ - Search backward:
? - Previous keyword occurrence:
N - Next keyword occurrence:
n - Use vi keys in buffer:
setw -g mode-keys vi - Show all buffers:
list-buffers - Copy entire visible contents of pane to a buffer:
capture-pane - Show all buffers and paste selected:
choose-buffer
tmux Miscellaneous
- Detach and keep the session running:
tmux detachorCTRL+bthend - Show a list of all key bindings:
CTRL+bthen? - Command mode:
CTRL+bthen: - Reload configuration file:
tmux source-file ~/.tmux.conforCTRL+bthenr - Disconnect all other clients:
tmux detach-client -a - Force tmux to assume 256 colors:
tmux -2 - Send the prefix key to the current pane:
CTRL+bthenb - List all commands:
list-commands
Step-by-Step Examples
Example 1: Basic Multi-Pane Development Setup
- Start new session:
tmux new -s dev - Split horizontally for code editor:
CTRL+bthen" - Move to bottom pane:
CTRL+bthenDown Arrow - Split vertically for terminal and logs:
CTRL+bthen% - Navigate between panes:
CTRL+bthen arrow keys - Zoom into editor pane:
CTRL+bthenUp Arrow→CTRL+bthenz
Example 2: Resizing Panes for Better Layout
- Create horizontal split:
CTRL+bthen" - Top pane too small? Make it bigger:
CTRL+bthenCTRL+Down(repeat as needed) - Bottom pane now too big? Make it smaller:
CTRL+bthenCTRL+Up - For faster resizing:
CTRL+bthenALT+Down(resizes by 5 cells)
Example 3: Managing Multiple Projects
- Create first project session:
tmux new -s project1 - Work on project1, then detach:
CTRL+bthend - Create second project session:
tmux new -s project2 - Switch between projects:
tmux attach -t project1orCTRL+bthens - List all sessions:
tmux ls
Example 4: Copy Mode Workflow
- Enter copy mode:
CTRL+bthen[ - Navigate to text you want: arrow keys or
h/j/k/l - Start selection:
Spacebar - Extend selection: arrow keys
- Copy selection:
Enter - Move to different pane:
CTRL+bthen arrow key - Paste:
CTRL+bthen]
Example 5: Window and Pane Navigation
- Create new window:
CTRL+bthenc - Split into panes:
CTRL+bthen"→CTRL+bthen% - Show pane numbers:
CTRL+bthenq→ press2to jump to pane 2 - Switch windows:
CTRL+bthen1(for window 1) - Go back to previous window:
CTRL+bthenp
Example 6: Advanced Pane Management
- Create 4-pane layout:
- Start:
CTRL+bthen" - Top pane:
CTRL+bthen% - Bottom pane:
CTRL+bthenDown Arrow→CTRL+bthen%
- Start:
- Resize panes for code/terminal/logs/monitoring:
- Make code pane (top-left) larger:
CTRL+bthenCTRL+Right(repeat) - Make logs pane (bottom-right) taller:
CTRL+bthenCTRL+Up
- Make code pane (top-left) larger:
- Swap panes if needed:
CTRL+bthen{or}
Tags:
Linux, Tmux, Cheatsheet