Session Management
Creating & Attaching
tmux # new session tmux new -s work # new named session tmux attach -t work # attach to session tmux attach -dt work # detach others, attach
Session Commands
tmux lsList all sessions
tmux kill-session -t workKill a named session
tmux kill-serverKill the tmux server and all sessions
tmux rename-session -t old newRename a session
Prefix dDetach from current session
Prefix $Rename current session
Prefix sList sessions (interactive)

Default prefix is Ctrl-b

Windows
Window Key Bindings
Prefix cCreate new window
Prefix ,Rename current window
Prefix &Close current window (confirm)
Prefix nNext window
Prefix pPrevious window
Prefix 0-9Switch to window by number
Prefix wList windows (interactive picker)
Prefix lToggle to last active window
Window Commands
tmux new-window -t work # new window in session tmux swap-window -t 0 # move window to index 0 tmux move-window -t 3 # renumber to index 3
Panes
Splitting & Closing
Prefix %Split horizontally (left | right)
Prefix "Split vertically (top / bottom)
Prefix xClose current pane (confirm)
Prefix !Break pane into its own window
Prefix zToggle pane zoom (full window)
Resizing Panes
Prefix Ctrl-ArrowResize by 1 cell
Prefix Alt-ArrowResize by 5 cells
Prefix SpaceCycle through layouts

Layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, tiled

Navigation
Moving Between Panes
Prefix ArrowMove to pane in direction
Prefix oCycle to next pane
Prefix qShow pane numbers, then press number to jump
Prefix {Swap pane with previous
Prefix }Swap pane with next
Moving Between Sessions
Prefix (Switch to previous session
Prefix )Switch to next session
Prefix sSession picker (tree view)
Prefix wWindow picker across all sessions
Copy Mode
Entering & Navigating
Prefix [Enter copy mode
qExit copy mode
Arrow / hjklMove cursor (vi mode)
Ctrl-u / Ctrl-dPage up / page down
g / GJump to top / bottom
/Search forward
?Search backward
n / NNext / previous search match
Selecting & Copying
SpaceStart selection (vi mode)
EnterCopy selection and exit
Prefix ]Paste buffer
vToggle rectangle selection (vi mode)

Enable vi mode: set -g mode-keys vi

Configuration
Common Settings (~/.tmux.conf)
set -g mouse on # enable mouse set -g base-index 1 # windows start at 1 set -g renumber-windows on # renumber on close set -g default-terminal "tmux-256color" set -g history-limit 50000
Reload Config
tmux source-file ~/.tmux.conf # from shell # or Prefix : then type: source-file ~/.tmux.conf
Status Bar
Status Bar Options
set -g status-position top set -g status-style "bg=black,fg=white" set -g status-left "[#S] " set -g status-right "%H:%M %d-%b" set -g status-interval 5
Format Variables
#SSession name
#IWindow index
#WWindow name
#PPane index
#HHostname
#TPane title
Key Bindings
Custom Bindings
# change prefix to Ctrl-a unbind C-b set -g prefix C-a bind C-a send-prefix # vim-style pane navigation bind h select-pane -L bind j select-pane -D bind k select-pane -U bind l select-pane -R
Binding Syntax
bind X commandBind Prefix + X to command
bind -n M-Left prevBind without prefix (Alt-Left)
bind -r H resize-pane -L 5Repeatable binding
unbind XRemove a binding
Prefix ?List all current key bindings
Scripting
Scripted Layouts
tmux new-session -d -s dev tmux send-keys -t dev "vim" Enter tmux split-window -h -t dev tmux send-keys -t dev "npm run dev" Enter tmux attach -t dev
Useful Commands
tmux send-keys -t sess 'cmd' EnterSend keystrokes to a session
tmux capture-pane -pPrint pane contents to stdout
tmux display-message '#S'Show a message / variable
tmux set-environment -g VAR valSet an environment variable
tmux list-keysList all key bindings
Common Patterns
Recommended ~/.tmux.conf
set -g mouse on set -g base-index 1 set -g mode-keys vi set -g status-position top set -g history-limit 50000 bind | split-window -h -c "#{pane_current_path}" bind - split-window -v -c "#{pane_current_path}"
Quick Recipes
Survive SSH disconnecttmux new -s work → disconnect → tmux attach -t work
Share sessionBoth users tmux attach -t same (read-only: -r)
Save scrollbacktmux capture-pane -S -3000 -p > log.txt
Kill stuck panePrefix x, or tmux kill-pane -t %N
Reorder windows:swap-window -s 3 -t 1