How to detach, list, and re-attach a tmux session?

By Romain Dorgueil

Short answer

tmux ls            # list running sessions
tmux attach -t projet   # re-attach to one (short: tmux a -t projet)

From inside a session, press prefix d to detach: tmux disappears but the session keeps running in the background. prefix s opens an interactive session picker.

Details

The whole point of tmux is that a session outlives the terminal attached to it. Three operations cover the daily loop.

Detach with prefix d, which runs detach-client. Your shells, running processes, and layout stay alive in the background; you just stop viewing them. Closing the terminal window does the same thing.

List with tmux ls (short for list-sessions). It prints one line per session with its name and window count:

tmux ls
# alpha: 1 windows (created Mon Jun  8 08:13:49 2026)
# beta: 1 windows (created Mon Jun  8 08:13:49 2026)

Re-attach with tmux attach -t name (or tmux a -t name). Without -t, tmux attaches to the most recently used session.

If you would rather pick from a list than type a name, prefix s runs choose-tree -Zs: an interactive tree of sessions, where -Z opens it zoomed to full screen. Move with the arrow keys and press Enter to switch.

Verified on tmux 3.2a.