Tmux is a terminal multiplexer that allows you to switch between multiple terminal sessions and windows.
Basic Commands
| Command | Description |
|---|
tmux | Start a new tmux session |
tmux new -s name | Start a new session with name |
tmux ls | List all tmux sessions |
tmux a | Attach to the last session |
tmux a -t name | Attach to a session with name |
tmux kill-session -t name | Kill session with name |
exit or Ctrl+A d | Detach from current session |
Session Management
| Command | Description |
|---|
Ctrl+A $ | Rename current session |
Ctrl+A d | Detach from session |
Ctrl+A s | List sessions |
Ctrl+A ( | Move to previous session |
Ctrl+A ) | Move to next session |
Window Management
| Command | Description |
|---|
Ctrl+A c | Create new window |
Ctrl+A , | Rename current window |
Ctrl+A & | Kill current window |
Ctrl+A n | Move to next window |
Ctrl+A p | Move to previous window |
Ctrl+A 0-9 | Switch to window 0-9 |
Ctrl+A w | List windows |
Ctrl+A f | Find window |
Ctrl+A . | Move window to another session |
Pane Management
| Command | Description |
|---|
Ctrl+A " | Split pane horizontally |
Ctrl+A % | Split pane vertically |
Ctrl+A arrow | Navigate between panes |
Ctrl+A o | Cycle through panes |
Ctrl+A q | Show pane numbers |
Ctrl+A q 0-9 | Switch to pane by number |
Ctrl+A z | Toggle pane zoom |
Ctrl+A ! | Convert pane into window |
Ctrl+A x | Kill current pane |
Ctrl+A } | Swap with next pane |
Ctrl+A { | Swap with previous pane |
Ctrl+A Ctrl+arrow | Resize pane |
Ctrl+A Alt+arrow | Resize pane (5 cells at a time) |
Ctrl+A spacebar | Toggle between pane layouts |
Copy Mode
| Command | Description |
|---|
Ctrl+A [ | Enter copy mode |
Ctrl+A ] | Paste buffer |
q | Quit copy mode |
Space | Start selection (in copy mode) |
Enter | Copy selection (in copy mode) |
/ | Search forward (in copy mode) |
? | Search backward (in copy mode) |
n | Next search match |
N | Previous search match |
Miscellaneous
| Command | Description |
|---|
Ctrl+A : | Enter command mode |
Ctrl+A t | Show clock |
Ctrl+A ? | List all key bindings |
Ctrl+A ~ | Show messages |
Ctrl+A i | Show session info |
Ctrl+A r | Reload tmux configuration |
Common Configuration (for your .tmux.conf)
# Remap prefix from Ctrl+B to Ctrl+A
# Split panes using | and -
bind r source-file ~/.tmux.conf \; display "Config reloaded!"
# Don't rename windows automatically
set-option -g allow-rename off
# vim-like pane navigation
# Set 256 colour terminal
set -g default-terminal "screen-256color"
# Start window numbering at 1
setw -g pane-base-index 1
# Increase scrollback buffer size
set -g history-limit 10000
Useful Plugins (with TPM - Tmux Plugin Manager)
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect' # Save/restore sessions
set -g @plugin 'tmux-plugins/tmux-continuum' # Auto save sessions
set -g @plugin 'tmux-plugins/tmux-yank' # Better copy/paste
set -g @plugin 'dracula/tmux' # Dracula theme
# Initialize TMUX plugin manager
run '~/.tmux/plugins/tpm/tpm'
Plugin Shortcuts
| Command | Description |
|---|
Ctrl+A I | Install plugins |
Ctrl+A U | Update plugins |
Ctrl+A Alt+u | Uninstall unused plugins |
Ctrl+A Ctrl+s | Save session (with tmux-resurrect) |
Ctrl+A Ctrl+r | Restore session (with tmux-resurrect) |