tmux guide: sessions, panes, config and running AI agents that keep going
tmux has been the standard terminal multiplexer on Unix systems since its first release in 2007, when Nicholas Marriott wrote it as a modern replacement for GNU Screen. It is written in C, released under the permissive ISC license, and part of OpenBSD's base system. Releases come roughly every six months. Version 3.6, released on November 26, 2025, added scrollbars for panes and support for terminals that report light or dark themes, and later releases have continued that pace.
The rise of AI coding agents has given tmux a new audience. Agents can run for an hour on a large task, and tmux is the simplest way to start one on a remote machine, disconnect and check back later.
The three building blocks
- A session is a collection of windows that keeps running on the machine where tmux runs. You can detach from it and attach again later, from the same or a different terminal.
- A window is like a tab inside a session.
- A pane is a split inside a window. Each pane runs its own shell.
A tmux server process holds all of this. It starts automatically with your first session and keeps running until the last session ends.
Installing tmux
| System | Command |
|---|---|
| macOS | brew install tmux |
| Debian, Ubuntu | sudo apt install tmux |
| Fedora | sudo dnf install tmux |
| Arch | sudo pacman -S tmux |
| Windows | Install inside WSL with the Linux command |
Commands you need on day one
Every key binding starts with the prefix, Ctrl-b by default. Press the prefix, release it, then press the next key.
| Action | Command or keys |
|---|---|
| New named session | tmux new -s work |
| List sessions | tmux ls |
| Attach to a session | tmux attach -t work |
| Detach | Ctrl-b d |
| Split left and right | Ctrl-b % |
| Split top and bottom | Ctrl-b " |
| Move between panes | Ctrl-b then an arrow key |
| Zoom a pane to full window | Ctrl-b z (again to unzoom) |
| New window | Ctrl-b c |
| Switch window | Ctrl-b 0 to 9, or Ctrl-b n and p |
| Scroll back (copy mode) | Ctrl-b [, then arrows or Page Up, q to exit |
| List key bindings | Ctrl-b ? |
| Kill a session | tmux kill-session -t work |
A starter config
tmux reads ~/.tmux.conf (or ~/.config/tmux/tmux.conf). A short config that many people start from:
# Use Ctrl-a as prefix, like GNU Screen
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# Mouse support: click panes, drag borders, scroll
set -g mouse on
# Start window and pane numbers at 1
set -g base-index 1
setw -g pane-base-index 1
# Easier splits that open in the current folder
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# More scrollback and true color
set -g history-limit 50000
set -g default-terminal "tmux-256color"
# Reload config
bind r source-file ~/.tmux.conf \; display "Reloaded"
Reload with tmux source-file ~/.tmux.conf or the r binding above.
What changed in tmux 3.6
The 3.6 release added options that users had asked for over years:
- Pane scrollbars.
pane-scrollbarsturns on a scrollbar at the side of each pane, with options for position and style. - Theme reporting. tmux can tell programs whether the terminal uses a light or dark theme, so editors and tools inside tmux can switch colors to match.
- Copy mode improvements, including new styles for the cursor position and selection, and new scroll commands.
- Other options, such as
no-detach-on-destroyfor clients and a limit on nestedsource-filecalls.
Later releases have built on this. Check tmux -V and the CHANGES file for what your version supports.
Running AI agents with tmux
A typical setup for running an agent on a remote server:
- SSH into the server and start a session:
tmux new -s agent. - Split the window: the agent in the left pane,
git diff --stator your test watcher on the right. - Start the agent, such as Claude Code or Codex CLI, and give it a task.
- Detach with
Ctrl-b dand close your laptop. - Later, SSH in and
tmux attach -t agentto see progress or answer a prompt.
Because tmux can be scripted, you can also drive agents from outside. tmux send-keys -t agent "run the tests" Enter types into a pane, and tmux capture-pane -p -t agent prints what is on screen. Some orchestration tools use these commands to run several agents in parallel panes and collect their output.
Set the agent's permissions with care before you detach. An agent waiting for approval will sit idle until you return, and an agent with full permissions will act without anyone watching. A container or a separate user account on the server limits the damage if something goes wrong.
Plugins
The tmux plugin manager (TPM) installs plugins listed in your config. Popular ones include:
- tmux-resurrect and tmux-continuum, which save and restore sessions across server reboots.
- tmux-sensible, a set of agreed-upon defaults.
- tmux-yank, which copies to the system clipboard.
Limits
Learning curve. The prefix-key model takes a few days to feel natural.
Sessions do not survive a reboot of the server without a plugin such as tmux-resurrect, and even then running programs restart from scratch.
Clipboard and colors need setup. Copying to your local clipboard over SSH depends on your terminal supporting OSC 52. True color needs the right default-terminal setting and a terminal that supports it.
No native Windows version. Use WSL.
tmux compared with alternatives
| Tool | What it is | Best for |
|---|---|---|
| tmux | Terminal multiplexer | Remote sessions, scripting, the same setup everywhere |
| GNU Screen | Older multiplexer | Systems where only Screen is installed |
| Zellij | Rust multiplexer with on-screen hints | People who want an easier start and built-in layouts |
| Terminal tabs and splits | Built into emulators | Local work that does not need to outlive the window |
For a fuzzy picker that works in tmux popups, see fzf. For a fast terminal to run tmux in, see Alacritty. The full list is in the terminal tools guide.
Frequently asked questions
What is tmux used for?
tmux keeps terminal sessions alive and organizes them. Its two main uses are persistence, where a session keeps running on a server after you disconnect so you can reattach later, and layout, where you split one window into panes to watch an editor, a test runner and logs side by side. Developers also use it to run AI coding agents for hours on a remote machine without keeping a laptop connected.
How do I install tmux?
On macOS, run brew install tmux. On Debian and Ubuntu, run sudo apt install tmux. On Fedora, sudo dnf install tmux, and on Arch, sudo pacman -S tmux. tmux does not run natively on Windows, so use it inside WSL. Check the version with tmux -V. Distribution packages can be a few releases behind the latest.
What are the most important tmux commands?
tmux new -s name starts a named session. Ctrl-b d detaches. tmux ls lists sessions. tmux attach -t name reattaches. Inside tmux, Ctrl-b % splits the pane left and right, Ctrl-b " splits it top and bottom, Ctrl-b and an arrow key moves between panes, Ctrl-b c creates a window and Ctrl-b followed by a number switches to that window. Ctrl-b [ enters copy mode to scroll back.
How do I keep an AI agent running after I disconnect?
SSH into the server, run tmux new -s agent, start the agent inside that session, then press Ctrl-b d to detach. The agent keeps running on the server. Later, SSH back in and run tmux attach -t agent to see where it is. Pair this with the agent's own permission settings, since nobody is watching while you are detached.
Should I use tmux or my terminal's built-in tabs and splits?
Use your terminal's tabs and splits if you only work on your own computer and do not need sessions to outlive the window. Use tmux when you work over SSH, need sessions that survive disconnects and reboots of your laptop, want the same layout on every machine, or want to script and automate terminal sessions with commands such as send-keys and capture-pane.