TMUX
breif introduction to tmux
The leader key defaults to
Ctrl-b.
Session: the top-level unit of a workspace
| What | Key / command | Notes |
|---|---|---|
| New session (with a window) | tmux new -s <name> | first entry point |
| List sessions | tmux ls | |
| Switch session | tmux switch -t <name> | swap from inside the current one |
| Reattach to a session | tmux attach -t <name> | recover a dropped session |
| Kill a session | tmux kill-session -t <name> | |
| Detach | <leader> d / tmux detach | send it to the background |
| End a session | exit inside it, or <leader> :kill-session | closes every window and pane |
| Navigate sessions | <leader> ( previous / <leader> ) next / <leader> s chooser | |
| Rename a session | <leader> $ | |
| Copy mode (scrolling) | <leader> [ | scroll and copy |
| Leave without switching | <leader> d | keep the session, return to the shell |
Window: an independent screen you use like a tab
| What | Key / command |
|---|---|
| New window | <leader> c |
| Go to by number | <leader> <number> |
| Move a window | <leader> . <number> |
| Previous / next | <leader> p / <leader> n |
| List windows | <leader> w |
| Find a window | <leader> f |
| Rename | <leader> , |
| Kill | <leader> & |
Pane: splitting one screen like Lego
| What | Key / command | Notes |
|---|---|---|
| Split left/right | <leader> % | vertical divider |
| Split top/bottom | <leader> " | horizontal divider |
| Move between panes | <leader> + arrow key / <leader> o (next) | |
| Show pane numbers | <leader> q | brief numeric overlay |
| Current pane to its own window | <leader> ! | break-pane |
| Rotate panes | <leader> Ctrl-o counter-clockwise / <leader> Alt-o clockwise | |
| Resize a pane (quickly) | hold <leader> and press an arrow key | |
| Resize by 1 cell / 5 cells | <leader> Ctrl+arrow / <leader> Alt+arrow | |
| Resize precisely | <leader> :resize-pane -L/R/U/D <N> | |
| Close a pane | exit, or <leader> x / Ctrl-d | |
| Show pane shortcuts | <leader> ? | full key-binding help |
Advanced tricks for multiple splits
# Give every pane the same height/width
tmux select-layout even-horizontal # even across
tmux select-layout even-vertical # even down
# 3x1 grid (preset layout)
tmux select-layout tiled
# Pull a pane from another session/window into this one
tmux join-pane -s 1.2 # the active pane of "session 1, window 2"
# Maximise / restore just the pane
(<leader>) z
Scroll and copy mode
# .tmux.conf example (macOS clipboard integration)
set -g mouse on # enable mouse scrolling and clicks
bind -T copy-mode-vi y send -X copy-pipe-and-cancel "pbcopy"
- Enter:
(<leader>) [→ Vim-style movement and selection - Select: space to start a block selection → enter to copy
.tmux.conf example
# Change the leader to Ctrl-a
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# Pane border colours
set -g pane-border-style "fg=colour238"
set -g pane-active-border-style "fg=colour45"
After editing, run tmux source-file ~/.tmux.conf to apply it immediately, or check in a new session.