tmux command cheat sheet for SSH
On this page
Start a named tmux session with tmux new -s work, detach without stopping it using Ctrl+b d, list running sessions with tmux ls, and reattach later with tmux attach -t work. Every command below works over SSH on macOS and Linux.
This page is the quick reference for what tmux does and why agents need it. Bookmark the commands you type most, or skip typing prefix chords altogether when connecting from a phone.
Sessions: create, list, attach, detach
A session is the unit that survives an SSH drop. Name every long-running session after the repository or task so tmux ls stays readable.
| Goal | Command | Notes |
|---|---|---|
| Start a named session | tmux new -s work |
Creates session work and attaches immediately |
| Attach or create if missing | tmux new -As work |
Safe single command to use in scripts or shortcuts |
| List active sessions | tmux ls |
Shows session names, window counts, and attach state |
| Reattach to a session | tmux attach -t work |
Short form: tmux a -t work |
| Detach and leave it running | Ctrl+b d |
Returns to your outer shell; processes keep running |
| Rename current session | Ctrl+b $ |
Type the new name and press Enter |
| Kill a finished session | tmux kill-session -t work |
Stops all windows and panes inside work |
Windows and panes
Press Ctrl+b, release both keys, then press the command key. Inside a session, windows act like tabs and panes split one window into tiles.
| Action | Shortcut |
|---|---|
| New window | Ctrl+b c |
| Next / previous window | Ctrl+b n / Ctrl+b p |
| Rename current window | Ctrl+b , |
| Split pane top / bottom | Ctrl+b " |
| Split pane left / right | Ctrl+b % |
| Move between panes | Ctrl+b then arrow key |
| Zoom or unzoom current pane | Ctrl+b z |
| Close current pane | exit or Ctrl+d |
On a phone screen, separate sessions or zoomed panes (Ctrl+b z) are easier to read than side-by-side splits.
Scrolling and copy mode
Normal terminal scrollback does not work inside tmux until you enter copy mode or enable mouse support.
- Enter scroll / copy mode: press
Ctrl+b [, then use arrow keys,PageUp, or/to search backward. - Exit copy mode: press
qorEscto return to the live prompt. - Switch sessions interactively: press
Ctrl+b sfor a list of sessions you can pick with arrow keys.
A minimal ~/.tmux.conf for SSH and mobile
Add these four lines to ~/.tmux.conf on your host, then reload with tmux source-file ~/.tmux.conf:
set -g mouse on
set -g history-limit 10000
set -sg escape-time 10
set -g focus-events on
mouse onlets touch scrolling and pane taps work over SSH.history-limit 10000keeps enough lines to inspect long agent diffs and test output.escape-time 10removes the noticeable lag after pressingEscin Vim or CLI agents.focus-events onlets editors and terminal tools detect when you switch back to a pane.
Skipping prefix keys from your phone
Typing Ctrl+b chords on an iPhone or Android keyboard slows down quick check-ins. Agentmux lists your running tmux sessions on connect, reattaches with one tap, and keeps a 14-day full-feature trial followed by a free single-server tier. If you have not set up your host yet, start with the setup wizard.