Click any command to expand the explanation. The default prefix key is Ctrl+b.
π¦ Sessions
tmux new / attach / detach session
# From the terminal tmux # New unnamed session tmux new -s myproject # New named session tmux ls # List sessions tmux attach -t myproject # Reattach tmux kill-session -t myprojectThe key concept: detach from a session, and it keeps running in the background. Reattach later, even from a different SSH connection.Inside tmux (prefix = Ctrl+b)
Ctrl+b d # Detach (session keeps running) Ctrl+b s # List sessions (interactive picker) Ctrl+b $ # Rename current session Ctrl+b ( # Previous session Ctrl+b ) # Next session
πͺ Windows (Tabs)
Create, switch, rename windows window
Ctrl+b c # Create new window Ctrl+b , # Rename current window Ctrl+b w # List windows (interactive picker) Ctrl+b n # Next window Ctrl+b p # Previous window Ctrl+b 0-9 # Switch to window by number Ctrl+b & # Kill current window Ctrl+b l # Toggle last active windowWindows are like tabs. Each window has its own shell.
π Panes (Splits)
Split, navigate, resize panes pane
# Split Ctrl+b % # Split vertically (left/right) Ctrl+b " # Split horizontally (top/bottom)Navigate
Ctrl+b ββββ # Move between panes (arrow keys) Ctrl+b o # Cycle through panes Ctrl+b q # Show pane numbers, then press number to jump Ctrl+b ; # Toggle last active pane
Resize
Ctrl+b Ctrl+ββββ # Resize in arrow direction (hold Ctrl) Ctrl+b z # Toggle pane zoom (fullscreen/restore)
Rearrange
Ctrl+b { # Swap pane left Ctrl+b } # Swap pane right Ctrl+b Space # Cycle through layouts
Close
Ctrl+b x # Kill current pane (with confirmation) exit # Or just type exit
π Copy Mode
Scroll and copy text copy
# Enter copy mode Ctrl+b [ # Enter copy mode (scroll with arrow keys) q # Exit copy modeIn copy mode (vi keys if set-window-option -g mode-keys vi)
Space # Start selection Enter # Copy selection / # Search forward ? # Search backward n # Next search result g # Go to top G # Go to bottom
Paste
Ctrl+b ] # Paste buffer
βοΈ Configuration (~/.tmux.conf)
Essential config config
# ~/.tmux.confAfter editing, reload withChange prefix to Ctrl+a (easier to reach)
unbind C-b set -g prefix C-a bind C-a send-prefix
Enable mouse (scroll, click panes, resize)
set -g mouse on
Start window numbering at 1
set -g base-index 1 setw -g pane-base-index 1
Vi mode for copy
setw -g mode-keys vi
Easier splits (| and -)
bind | split-window -h -c β#{pane_current_path}β bind - split-window -v -c β#{pane_current_path}β
Reload config
bind r source-file ~/.tmux.conf ; display βReloaded!β
Increase scrollback
set -g history-limit 50000
Faster escape (for vim users)
set -sg escape-time 0
True color support
set -g default-terminal βtmux-256colorβ set -ag terminal-overrides β,xterm-256color:RGBβ
Ctrl+b :source-file ~/.tmux.conf or restart tmux.
β‘ Quick Reference
Most-used commands at a glance reference
# Terminal commands tmux # Start tmux new -s name # Start named tmux a -t name # Attach tmux ls # List tmux kill-server # Kill everythingInside tmux (Ctrl+b thenβ¦)
d detach c new window n/p next/prev window % split vertical β split horizontal ββββ switch pane z zoom pane x kill pane [ copy mode , rename window $ rename session s session picker w window picker ? list all keybindings