πŸ“‹ Cheat Sheets

tmux Cheat Sheet β€” Sessions, Windows, and Panes


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 myproject

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

The key concept: detach from a session, and it keeps running in the background. Reattach later, even from a different SSH connection.

πŸͺŸ 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 window
Windows 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 mode

In 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.conf

Change 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”

After editing, reload with 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 everything

Inside 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