tmux Cheatsheet

3.4

Essential tmux shortcuts for sessions, windows, and panes

Official docs →

If you've ever closed a terminal tab and watched a long-running process vanish into the void, tmux is the fix you didn't know you needed. It's a terminal multiplexer — a fancy way of saying it lets you run multiple terminal sessions inside a single window, split your screen into panes, and (here's the killer feature) detach from everything and come back later with your entire workspace intact. SSH into a server, start a job, detach, close your laptop, go home, reattach. It's all still there.

The learning curve is real. tmux speaks its own language of prefix keys, and at first it feels like you're typing incantations. The default prefix is Ctrl-b, which means almost every command starts with that combo followed by another key. It's awkward at first — your fingers will rebel — but muscle memory kicks in faster than you'd expect. Within a week or two, you'll be splitting panes and jumping between sessions without thinking.

This cheatsheet covers the shortcuts you'll reach for daily. We're skipping the obscure stuff and focusing on what actually matters: managing sessions so your work survives disconnects, juggling windows like browser tabs, splitting panes for side-by-side workflows, and copy mode for when you need to scroll or grab text. If you pair tmux with a good editor like Neovim, you've basically built yourself a custom IDE that runs anywhere with a terminal.

Sessions

Sessions are your top-level workspaces. Think of them like separate desktops — one for each project.

Sessions
tmux new -s name
Create a new named session
Ctrl-bd
Detach from current session
tmux ls
List all sessions
tmux attach -t name
Attach to a named session
tmux a
Attach to last session
Ctrl-bs
Interactive session picker
Ctrl-b$
Rename current session
Ctrl-b(
Switch to previous session
Ctrl-b)
Switch to next session
tmux kill-session -t name
Kill a specific session
tmux kill-server
Nuclear option — kill everything

Windows

Windows are tabs inside a session. Each window fills the whole terminal.

Windows
Ctrl-bc
Create a new window
Ctrl-b,
Rename current window
Ctrl-b&
Close current window (with confirmation)
Ctrl-bn
Next window
Ctrl-bp
Previous window
Ctrl-b0-9
Jump to window by number
Ctrl-bl
Toggle to last active window
Ctrl-bw
Interactive window list (tree view)
Ctrl-b.
Move window to a new index

Panes

Panes split a window into multiple terminals. This is where tmux really shines.

Panes
Ctrl-b%
Split pane vertically (left/right)
Ctrl-b"
Split pane horizontally (top/bottom)
Ctrl-bArrow Keys
Navigate between panes
Ctrl-bq
Show pane numbers, then press number to jump
Ctrl-bz
Zoom pane to full screen (toggle)
Ctrl-bx
Close current pane (with confirmation)
Ctrl-b{
Swap pane with previous
Ctrl-b}
Swap pane with next
Ctrl-bSpace
Cycle through pane layouts
Ctrl-bCtrl-Arrow Keys
Resize pane in arrow direction
Ctrl-b!
Convert pane into its own window

Copy Mode

Copy mode lets you scroll through output, search, and copy text — no mouse required.

Copy Mode
Ctrl-b[
Enter copy mode
q
Exit copy mode
Arrow Keys / PgUp / PgDn
Navigate through buffer
g
Jump to top of buffer
G
Jump to bottom of buffer
/
Search forward
?
Search backward
n
Next search match
N
Previous search match
Space
Start selection
Enter
Copy selection and exit copy mode
Ctrl-b]
Paste from tmux buffer

Custom Prefix Key

The default Ctrl-b prefix works, but many people remap it. Here are common patterns.

Custom Prefix Key Patterns
set -g prefix C-a
Remap prefix to Ctrl-a (screen-style)
set -g prefix C-Space
Remap prefix to Ctrl-Space (popular modern choice)
unbind C-b
Unbind the old prefix after remapping
bind C-a send-prefix
Send prefix to nested tmux with double tap
bind r source ~/.tmux.conf
Bind r to reload config instantly

Tips

Add set -g mouse on to your ~/.tmux.conf to enable mouse support. You'll be able to click panes, resize by dragging borders, and scroll with your wheel. It's not cheating — it's practical.

The tmux-resurrect plugin saves your entire tmux environment (sessions, windows, panes, even running programs) and restores it after a reboot. Pair it with tmux-continuum for automatic saving. Install both via TPM (Tmux Plugin Manager) and never lose a layout again.

Working with nested tmux sessions (local tmux + remote tmux over SSH)? Press your prefix twice to send it to the inner session. If your prefix is Ctrl-b, hitting Ctrl-b Ctrl-b sends the prefix to the remote tmux. Alternatively, remap the remote prefix to something different to avoid the gymnastics entirely.

Copy mode uses vi-style keybindings by default if your $EDITOR is set to vi/vim/nvim. Otherwise it uses emacs-style. Force vi mode with set -g mode-keys vi in your config — it pairs perfectly if you're already a Neovim user.

Use Ctrl-b z (zoom) constantly. It toggles the current pane to fill the whole window and back. Perfect for when you need to focus on one pane's output without rearranging your layout. The zoomed pane gets a Z flag in the status bar so you don't forget.

Start tmux with tmux new -s project-name instead of bare tmux. Named sessions are infinitely easier to manage when you're juggling multiple projects. tmux ls becomes actually useful when your sessions have real names instead of 0, 1, 2.

Add set -g base-index 1 and set -g pane-base-index 1 to your config. This makes window and pane numbering start at 1 instead of 0, which matches the physical layout of number keys on your keyboard. Reaching for Ctrl-b 1 to get your first window just feels right.

Related Tools