GuidesRunning & maintaining

tmux cheat sheet: keys, commands and config (tmux 3.8)

Every tmux key and command by task: sessions, windows, panes, copy mode, config and reload, plus send-keys, Shift+Enter and clipboard for coding agents.

December 2, 2026The Everpod team
The short answer

Every tmux key starts with the prefix, Ctrl-b, then a key: d detaches, c opens a window, % and " split the pane, [ enters copy mode to scroll, : opens the command line and ? lists every binding. From the shell, tmux new -As work attaches to the session work, creating it if needed. Settings go in ~/.tmux.conf or ~/.config/tmux/tmux.conf and take effect with tmux source-file. As of December 2, 2026 the current release is 3.8, which turns the mouse on by default; Ubuntu 24.04 ships 3.4 and 26.04 ships 3.6a, where it is off.

The tables below write the prefix as C-b, the manual’s notation: press Ctrl and b together, let go, then press the key. M- is Alt (Meta). Why tmux matters for an agent on a server, and its five essential commands, are in what tmux is; this page is the reference to keep open.

Which tmux you have

tmux -V prints the version. Several defaults changed recently, so the version decides how a fresh tmux behaves:

VersionWhere you meet itWhat differs
3.8 (September 9, 2026)
The current release; build from source or a fast-moving distributionMouse on by default; C-b Tab fuzzy window switcher; built-in light and dark themes
3.7b
Ubuntu 26.10Floating panes (C-b *); mouse off
3.6a
Ubuntu 26.04 LTS (3.6a-2ubuntu0.2)Escape delay 10 ms; mouse off
3.4
Ubuntu 24.04 LTS (3.4-1ubuntu0.2)Escape delay 500 ms; no extended-keys-format; mouse off

The 500 ms escape delay on 3.4 is how long tmux waits after Esc to see whether a longer key sequence follows, so Esc in an agent or an editor feels slow until you set escape-time lower (the config below does). The 3.8 release notes say “it is very important to restart tmux entirely after upgrading”: a server started by the old version keeps running after the package changes, and restarting it ends every session in it, agents included.

Sessions

From the shell (new, attach and ls are the short forms of new-session, attach-session and list-sessions):

Command or keyWhat it does
tmux new -s api
Start a session named api and attach to it
tmux new -As api
Attach to api if it exists, otherwise create it
tmux new -d -s api -c ~/projects/api
Create it in the background, starting in that directory
tmux ls
List sessions
tmux attach -t api
Reattach
tmux attach -d -t api
Reattach and detach every other client on that session
tmux has-session -t api
Exit status 1 if api does not exist (for scripts)
tmux rename-session -t api web
Rename a session
tmux kill-session -t api
End the session and everything running in it
tmux kill-server
End every session and the tmux server
C-b d
Detach; everything keeps running
C-b D
Choose a client to detach
C-b s
Pick a session from a list
C-b ( / C-b )
Previous / next session
C-b L
Back to the last session
C-b $
Rename the current session

The two kill commands stop the programs inside without asking, a running agent included.

Windows

KeyWhat it does
C-b c
New window
C-b n / C-b p
Next / previous window
C-b 0 to C-b 9
Go to window 0 to 9 (numbering starts at 0)
C-b l
The window you were last in
C-b w
Choose a window from a tree of sessions and windows
C-b Tab / C-b S-Tab
Fuzzy switcher for windows / for sessions (3.8)
C-b ,
Rename the window
C-b .
Move the window to another index
C-b f
Search open windows for text
C-b &
Kill the window, after a y/n prompt

Panes

KeyWhat it does
C-b %
Split into left and right
C-b "
Split into top and bottom
C-b arrow
Move to the pane in that direction
C-b o
Next pane
C-b ;
The pane you were last in
C-b q
Show pane numbers briefly
C-b z
Zoom the pane to the full window, and back
C-b { / C-b }
Swap with the previous / next pane
C-b !
Break the pane out into its own window
C-b T
Set the pane’s title (3.8)
C-b *
New floating pane (3.7 and later)
C-b x
Kill the pane, after a y/n prompt

Resizing and layouts

Key or commandWhat it does
C-b C-arrow
Resize the pane one cell that way
C-b M-arrow
Resize it five cells
C-b Space
Cycle through the preset layouts
C-b M-1 to M-5
Even horizontal, even vertical, main horizontal, main vertical, tiled
C-b M-6 / M-7 (3.5 and later)
Main horizontal mirrored / main vertical mirrored
:resize-pane -x 50%
Set an exact width; -y for height, in cells or a percentage
:resize-pane -Z
Zoom, as C-b z

When a terminal keeps Ctrl- or Alt-arrow for itself, the resize-pane command at the command line does the same job.

Copy mode and scrollback

A pane’s earlier output lives in tmux’s history, not your terminal’s, so the terminal’s own scrollbar shows little. Enter copy mode with C-b [ or C-b PageUp. Its keys are emacs-style by default, and vi-style if VISUAL or EDITOR contains “vi” when the server starts, which is the case on many servers set up with EDITOR=vim. Force one with set -g mode-keys vi or emacs.

Actionemacs keysvi keys
Page up / down
PageUp / PageDownC-b / C-f
Top / bottom of history
M-< / M->g / G
Search down / up
C-s / C-r/ / ?
Next match
nn
Start a selection
C-SpaceSpace
Copy the selection
M-w or C-w (both copy and leave)Enter (copies and leaves)
Leave copy mode
qq

C-b ] pastes the last copy, C-b = picks from older ones and C-b # lists them. With the mouse on, dragging inside a pane selects and copies when you let go. To use your terminal’s own selection instead, hold Shift while dragging on most Linux terminals, or Option in iTerm2.

Each pane keeps 2,000 lines of history by default (history-limit). On 3.7 and later a new value applies to panes already open; on older versions only to new ones. A long agent session overflows 2,000 lines quickly, so raise it in the config.

The command line

C-b : opens tmux’s prompt in the status line. Anything you can run as tmux <command> from a shell can be typed there without the tmux. Ones worth knowing:

At the promptWhat it does
source-file ~/.tmux.conf
Reload the config
set -g mouse on
Turn the mouse on (or off) for this server
set -w synchronize-panes on
Type into every pane of the window at once; off to stop
show -g history-limit
Show an option’s current value
pipe-pane -o "cat >> ~/pane.log"
Log the pane’s output to a file; the same again stops it
list-keys
Every key binding (also C-b ?)

Synchronised panes send the same keys to every pane in the window that is not in copy mode, which is handy for running one command on several machines and dangerous if an agent is in one of the panes: what you type there becomes its prompt.

The config file

tmux reads /etc/tmux.conf, then ~/.tmux.conf, $XDG_CONFIG_HOME/tmux/tmux.conf and ~/.config/tmux/tmux.conf. The ~/.config location has been searched since 3.1, so it works on every current Ubuntu. The file is read only when the server starts, not for each new session, so after editing it either reload it into the running server:

tmux source-file ~/.tmux.conf
Copied

or end every session with tmux kill-server and start again. A starting config for running agents on a server:

set -g mouse on
set -g history-limit 50000
set -s escape-time 10
set -g allow-passthrough on
set -g focus-events on
set -s extended-keys on
set -as terminal-features 'xterm*:extkeys'
Copied

Line by line: the mouse for scrolling and resizing (already the default on 3.8); 50,000 lines of history per pane, which costs memory for each pane that fills it; a 10 ms escape delay, the default from 3.5, for 3.4 on Ubuntu 24.04; and the last four lines from Anthropic’s tmux section for Claude Code, explained below. To change the prefix to Ctrl-a, add set -g prefix C-a, unbind C-b and bind C-a send-prefix (so that C-a C-a still sends Ctrl-a to the program).

Coding agents in tmux on a server

One command to get in. From your own computer, this connects and lands you in the session, creating it the first time:

ssh -t you@your-server tmux new -As agent
Copied

-t makes SSH allocate a terminal, which tmux needs when SSH runs it directly. When the connection drops, only your client goes; the session and the agent carry on, and the same line gets you back. If a laptop is still attached when you pick up on a phone, tmux attach -d -t agent attaches and detaches the laptop.

A session per agent. Naming a session after the project keeps several agents apart, and tmux ls becomes the list of what is running. Start the shell first and the agent inside it, rather than the agent as the session’s command, so that when the agent exits the pane stays with its last output:

tmux new -d -s api -c ~/projects/api
tmux send-keys -t api 'claude' Enter
Copied

Use codex, opencode or pi in place of claude. In a script, tmux has-session -t api tells you whether the session is already there before creating it.

Sending keys to an agent from a script

tmux send-keys -t <target> types into a pane as if from the keyboard. The target is session, session:window or session:window.pane, for example api:0.1. Three things trip people up:

tmux send-keys -t api -l 'Run the test suite and fix what fails'
sleep 0.5
tmux send-keys -t api Enter
Copied

For a prompt kept in a file:

tmux load-buffer -b prompt ~/prompt.md
tmux paste-buffer -p -d -b prompt -t api
sleep 0.5
tmux send-keys -t api Enter
Copied

load-buffer - reads from standard input instead of a file. To read what the agent has printed, capture-pane -p writes the pane’s text to standard output; -S -200 starts 200 lines back in the history (-S - from the very start), and -J joins lines the screen had wrapped:

tmux capture-pane -p -J -t api -S -200
Copied

-e keeps colours as escape sequences, and on 3.8 -I adds the time each line entered the history. What a capture holds is the screen, so it shows the agent’s interface as drawn, not a clean transcript; for that, the agent’s own non-interactive mode is the better tool.

Shift+Enter and notifications for Claude Code, Codex and Pi

By default tmux passes on only standard keys, so Shift+Enter reaches a program inside it as plain Enter and the agent submits instead of starting a new line. Two settings fix it, both in the config above: set -s extended-keys on lets the program ask for modified keys, and terminal-features 'xterm*:extkeys' tells tmux your terminal can send them. Anthropic’s page then says to “detach from tmux, attach again, and restart Claude Code.” The terminal on your own computer still has to support Shift+Enter; Claude Code’s new-line keys has the list, and Ctrl+J works everywhere without setup.

Pi’s tmux page adds set -g extended-keys-format csi-u for tmux 3.5 and later, calling CSI-u “the most reliable format for forwarding modified keys through tmux”; on 3.4 that option does not exist and the line is an error, so leave it out on Ubuntu 24.04. OpenAI’s Codex documentation has no tmux section as of December 2026; the same extended-keys settings are what let any program inside tmux tell Shift+Enter from Enter.

Notifications are escape sequences an agent prints for your terminal to turn into a desktop alert, and tmux swallows them unless allow-passthrough is on. With on, only a pane you can see gets through: in Anthropic’s words, “a pane in a window you aren’t viewing sends none.” Set all to let hidden panes through as well, which is the case that matters when an agent finishes in another window. Codex chooses its method with tui.notification_method (auto, osc9 or bel) in its config. Alerts that reach your phone or another machine, which tmux cannot carry, are in Claude Code notifications.

Copying out of a remote session

Text copied in tmux on a server lands in a tmux buffer on the server. To get it onto your own computer’s clipboard, tmux sends it to your terminal as an OSC 52 escape sequence, which per tmux’s clipboard page “works over an ssh(1) connection even if X11 forwarding is not configured.” Your terminal has to accept it: iTerm2 needs it enabled in its preferences, GNOME Terminal and other VTE terminals do not support it, and Kitty appends to the clipboard rather than replacing it. Inside tmux, tmux info | grep Ms: shows whether tmux thinks your terminal can take it.

set-clipboardWhat happens
external (default)
tmux’s own copies go to your clipboard; programs in panes cannot set it
on
Programs in panes (an editor, an agent’s copy command) can set your clipboard too
off
Nothing leaves the server

on is what makes an agent’s or an editor’s own copy reach your laptop, and the wiki’s warning comes with it: “if a command can write text to a tmux pane, it can set the clipboard.” An agent reading web pages or untrusted files prints what it reads, so weigh that before turning it on.

Run Claude Code, Codex, OpenCode, Pi, Hermes or OpenClaw on an always-on developer pod.

A developer pod is a permanent cloud computer (VPS), set up and secured for you, with your pick of Claude Code, Codex, OpenCode, Pi, Hermes and OpenClaw installed. Run more agents at once than your laptop can hold, and keep them working when it’s closed. From $24 a month, built in about ten minutes.