A practical guide for terminal-savvy users new to tmux.
- Core Concepts
- Getting Started
- The Prefix Key
- Common Operations
- Display Issues & Fixes
- Gotchas & Pain Points
- Copy/Paste (The Hard Part)
- Session Management
- Quick Reference
Tmux has three levels of hierarchy:
Server
└── Sessions (like desktop workspaces)
└── Windows (like browser tabs)
└── Panes (split views within a window)
Session: A collection of windows. You can detach from a session and it keeps running in the background. This is tmux's killer feature.
Window: Like a tab. Each window fills the whole terminal. You switch between them.
Pane: A split within a window. You can have multiple panes visible at once.
# Start new session (anonymous)
tmux
# Start new session with a name (recommended)
tmux new -s myproject
# Start in a specific directory
tmux new -s myproject -c ~/code/myprojectThere are two ways to leave tmux:
| Action | What Happens |
|---|---|
Detach (` then d) |
Tmux keeps running in background. You can reattach later. |
Exit (type exit or Ctrl+D) |
Closes the pane/window/session. If last pane, session ends. |
Detach is usually what you want. Your processes keep running.
# List sessions
tmux ls
# Attach to most recent
tmux a
# Attach to specific session
tmux a -t myproject
# Attach to session, detaching other clients
tmux a -dt myprojectAlmost all tmux commands start with a prefix key.
Your prefix is: ` (backtick)
Default tmux uses
Ctrl+b, but this config changed it to backtick for easier access.
- Press backtick (
`) - Release it
- Press the command key
It's a sequence, not a chord. Think of it as "activating command mode."
` then d = detach
` then c = new window
` then v = vertical split
Since backtick is the prefix, to type an actual ` character:
` then ` = types a backtick
| Keys | Action |
|---|---|
` v |
Split vertically (left/right) |
` s |
Split horizontally (top/bottom) |
Ctrl+h/j/k/l |
Move between panes (vim-style, no prefix needed) |
` x |
Toggle zoom current pane (fullscreen) |
` j |
Resize pane down |
` k |
Resize pane up |
exit or Ctrl+d |
Close current pane |
| Keys | Action |
|---|---|
` c |
Create new window |
Alt+h or Alt+← |
Previous window |
Alt+l or Alt+→ |
Next window |
` 1-9 |
Jump to window by number |
` , |
Rename current window |
| Keys | Action |
|---|---|
` d |
Detach from session |
` w |
Session/window picker (interactive) |
` $ |
Rename session |
` N |
Create new worktree session |
This happens when programs output garbage or terminal gets confused.
# Inside tmux - refresh the display
# Press: ` then r
# Or run this command
tmux refresh-client
# Nuclear option - reset terminal
resetUsually happens when you resize your terminal window while detached.
# Detach and reattach
# Press: ` then d
tmux a
# Or force resize
tmux refresh-client -S# Reload config
# Press: ` then R
# Or manually
tmux source-file ~/.tmux.confCheck your TERM variable:
echo $TERM
# Should be: xterm-256color or screen-256colorIf wrong, add to your ~/.bashrc or ~/.zshrc:
export TERM=xterm-256colorTmux remembers the smallest attached client size. If you have multiple terminals attached to the same session:
# Detach other clients
tmux detach -a
# Or attach exclusively
tmux a -d- Make sure you release the prefix before pressing the next key
- Commands are case-sensitive:
D≠d - Check that config is loaded:
`thenR
Tmux has its own scrollback buffer, separate from your terminal's.
To scroll in tmux:
PageUp- enters copy mode and scrolls up- In copy mode:
j/kto scroll,qto exit
Or enable mouse mode (already enabled in this config):
- Just scroll with your mouse/trackpad
Tmux intercepts some keys. Use:
# Clear screen AND scrollback
Alt+u
# Or just clear (keeps scrollback)
clearAdd to your .vimrc or init.vim:
set termguicolors
set background=darkAnd ensure TERM is set correctly (see Display Issues above).
Mouse mode is enabled in this config. But if it's not working:
# Check mouse setting
tmux show -g mouse
# Should output: mouse on
# Enable it manually
tmux set -g mouse onThey shouldn't! This is tmux's main feature. But watch out for:
- Programs that detect no TTY and exit
- SSH sessions timing out (separate from tmux)
- Running
exitinstead of detaching
Always detach (` then d) instead of closing the terminal.
If you have tmux-resurrect plugin installed:
` then Ctrl+r = restore last saved session
Sessions auto-save every 15 minutes with tmux-continuum.
This config fixes that. But if it's not working, check the config has:
bind v split-window -h -c "#{pane_current_path}"
bind s split-window -v -c "#{pane_current_path}"
Just switch panes/windows - everything keeps running. That's the point!
# Start long-running command
yarn test --watch
# Press Ctrl+h/j/k/l to move to another pane
# Or Alt+l to go to next windowFixed in this config with escape-time 0. If you still see delay:
# Check current setting
tmux show -g escape-time
# Should be: 0This is tmux's most confusing feature. There are multiple clipboard systems interacting.
With mouse mode enabled:
- Hold Shift while selecting text with mouse
- Normal terminal copy (Ctrl+Shift+C or Cmd+C)
- Normal paste (Ctrl+Shift+V or Cmd+V)
Holding Shift bypasses tmux and lets your terminal handle it.
- Enter copy mode:
PageUpor`then[ - Navigate with vim keys (
hjkl,Ctrl+u/dfor page up/down) - Start selection:
Space - Move to end of selection: vim motions
- Copy:
Enter - Paste:
`then]
This uses tmux's internal clipboard (paste buffer).
To make tmux copy to your system clipboard, you need additional setup depending on your OS. This config doesn't include it by default.
For Linux (X11):
# Add to ~/.tmux.conf
bind -T copy-mode-vi y send -X copy-pipe-and-cancel "xclip -sel clip"For macOS:
bind -T copy-mode-vi y send -X copy-pipe-and-cancel "pbcopy"Good session names = easier management:
tmux new -s project-api # By project
tmux new -s feat-auth # By feature/branch
tmux new -s client-acme # By client# Create sessions for different contexts
tmux new -s main -d # -d = detached (don't attach yet)
tmux new -s api -d
tmux new -s frontend -d
# List them
tmux ls
# Switch between (inside tmux)
# Press: ` then w (interactive picker)
# Or: ` then s (tree view)This config includes plugins for session persistence:
| Plugin | What it does |
|---|---|
| tmux-resurrect | Manual save/restore |
| tmux-continuum | Auto-save every 15 min |
Commands:
` then Ctrl+s = Save session
` then Ctrl+r = Restore session
What's saved:
- Window/pane layouts
- Working directories
- Running programs (basic)
- Vim sessions (if configured)
What's NOT saved:
- Shell history in panes
- Environment variables
- Complex program state
| Keys | Action |
|---|---|
` d |
Detach (most important!) |
` c |
New window |
` v |
Split vertical |
` s |
Split horizontal |
Ctrl+h/j/k/l |
Move between panes |
Alt+h/l |
Previous/next window |
` w |
Session picker |
` R |
Reload config |
PageUp |
Scroll mode |
tmux # Start new session
tmux new -s NAME # Start named session
tmux ls # List sessions
tmux a # Attach to last session
tmux a -t NAME # Attach to named session
tmux kill-session -t X # Kill session
tmux kill-server # Kill everything| Keys | Layout |
|---|---|
` D |
Dev: Editor 60% | Terminal stack |
` T |
Test: Editor 70% | Runner 30% |
` W |
4 equal panes (worktree overview) |
# Show all keybindings
tmux list-keys
# Show all keybindings with prefix
tmux list-keys | grep "prefix"
# Show specific setting
tmux show -g <option>
# Custom help script (this config)
~/.tmux/scripts/tmux-help.shInside tmux: ` then ? shows keybindings (press q to exit).
~/.tmux.conf # Main config
~/.tmux/plugins/ # TPM plugins
~/.tmux/layouts/ # Custom layouts
~/.tmux/scripts/ # Helper scripts
~/.tmux/resurrect/ # Session saves (auto-created)
- Practice detach/attach - This is the core workflow
- Learn pane navigation -
Ctrl+hjklbecomes muscle memory - Use named sessions -
tmux new -s projectname - Install plugins - Press
`thenI(capital i) - Try the layouts -
`thenDfor dev layout