Tmux keeps terminal sessions running on a server after you disconnect. These are the commands for starting, attaching, detaching, listing and killing sessions, plus scrollback, mouse mode and the two config lines that make Tmux work well over SSH from an iPhone or iPad.
Everything here uses stock Tmux defaults, so the prefix is Ctrl-b. Press the prefix, let go, then press the next key.
A session is the thing that survives when the SSH connection drops. Name each one, so attaching later is one short command.
| Command | What it does |
|---|---|
tmux new -s work | Start a new session called work |
tmux ls | List sessions (short for tmux list-sessions) |
tmux attach -t work | Attach to the session called work |
tmux a | Attach to the most recent session |
tmux attach -d -t work | Attach and detach any other client, so the window resizes to this screen |
tmux new -A -s work | Attach to work if it exists, create it if it doesn't |
tmux rename-session -t work agents | Rename a session (inside Tmux: Ctrl-b $) |
tmux kill-session -t work | Kill one session and everything running in it |
tmux kill-session -a | Kill every session except the current one |
tmux kill-server | Kill all sessions and the Tmux server |
How to attach to a Tmux session you didn't name: run tmux ls, read the number at the start of the line, then tmux attach -t 0. Inside Tmux, Ctrl-b s shows a session list you can pick from.
Ctrl-b d detaches. The session and whatever runs in it keep going on the server, and tmux attach brings you back to the same screen. From a shell you can also run tmux detach.
Typing exit, or closing the last shell in the session, ends the session. That's the difference between exiting a Tmux session and detaching from it: detach to leave something running, exit to finish.
A dropped SSH connection counts as a detach. That is why Tmux matters on a phone: lock the screen, lose signal, or switch to another app, and a long job or an AI coding agent keeps running on the server.
A window is a full screen inside a session. A pane is a split of a window. On a phone screen, windows are usually easier to read than panes.
| Keys | What it does |
|---|---|
| Ctrl-b c | New window |
| Ctrl-b n / Ctrl-b p | Next / previous window |
| Ctrl-b 0 to 9 | Jump to a window by number |
| Ctrl-b w | Pick a window from a list |
| Ctrl-b , | Rename the current window |
| Ctrl-b & | Kill the current window (asks first) |
| Ctrl-b % | Split into left and right panes |
| Ctrl-b " | Split into top and bottom panes |
| Ctrl-b then an arrow key | Move to the pane in that direction |
| Ctrl-b z | Zoom the current pane to the full window, and back |
| Ctrl-b x | Kill the current pane (asks first) |
| Ctrl-b ? | List every key binding |
Tmux keeps its own history, so the terminal's normal scroll doesn't reach it. Two ways in:
set -g mouse on in ~/.tmux.conf, scrolling scrolls the Tmux history directly. On a touch screen that's what makes a swipe work.Tmux keeps 2,000 lines per pane by default. Agent output runs long, so raising it is worth it:
set -g history-limit 50000
The new limit applies to panes created after the change.
These go in ~/.tmux.conf on the server. Each one is a standard Tmux option.
# Scroll and select with a mouse, trackpad or finger
set -g mouse on
# More history per pane
set -g history-limit 50000
# Publish the session name as the terminal title
set -g set-titles on
set -g set-titles-string '#S'
# Let copies inside Tmux reach the client's clipboard (OSC 52)
set -g set-clipboard on
Reload without restarting Tmux:
tmux source-file ~/.tmux.conf
To have Claude or Cursor write a tailored version, add the free Shell Drop MCP connector and ask it for a phone-friendly tmux.conf.
What each line is for:
tmux set -g mouse on if you want it for the running server only.Shell Drop is a free SSH client for iPhone, iPad and iPhone Duo, built around Tmux. Here's how the commands above map to it.
set -g mouse on is in place, and a horizontal swipe changes sessions. The direction setting is in Settings > Terminal > Tmux > Scrolling, along with the mouse line to copy.set-titles lines, each tab takes its Tmux session name. Turn it on in Settings > Terminal > Tmux > Tab-name sync.set -g set-clipboard on and Settings > Agents > Let server send to clipboard switched on, text the server copies lands on the phone, ready to paste in another app.The terminal app for iPhone page covers the SSH setup, and Claude Code on iPhone and Codex on iPhone cover running a coding agent in a Tmux session.
Run tmux ls to list sessions, then tmux attach -t name with the session's name or number. tmux a attaches to the most recent one, and tmux new -A -s name attaches if the session exists and creates it if not.
Press Ctrl-b, then d. The session keeps running on the server and tmux attach brings it back. Typing exit closes the shell, and closing the last shell ends the session.
tmux kill-session -t name kills one session. tmux kill-session -a kills every session except the current one, and tmux kill-server kills them all.
Press Ctrl-b then [ to enter copy mode, move with the arrow keys or Page Up, and press q to leave. Or add set -g mouse on to ~/.tmux.conf and scroll with a mouse, trackpad or swipe.
It turns on Tmux mouse mode: scrolling moves through the Tmux history, clicking selects panes and windows, and dragging selects text. Put it in ~/.tmux.conf, then run tmux source-file ~/.tmux.conf.
Yes. Tmux runs on the server, so any SSH client can attach to it. Shell Drop adds a Tmux prefix on the toolbar, swipe scrolling, tab names from session names and auto-attach for restored tabs. It is free.