How to manage tmux clients (list, kick out, disconnect)?
Short answer
tmux list-clients -t projet # who is attached (short: lsc)
tmux attach -d -t projet # attach here and detach every other client
tmux detach-client -a # detach all clients except the current one
tmux detach-client -t <client> # detach one specific client
Details
A session can have several clients attached at once: your laptop terminal, a second window, an SSH login from elsewhere. That is useful for pairing, but it also leaves a session “stuck” on a terminal you walked away from.
tmux list-clients -t name (alias lsc) shows every client on a session, one per line, with its
name and the size it is rendering at.
tmux attach -d -t name attaches the session where you are and detaches all other clients in one
step. This is the command for “I left it open on the other machine, give it back to me here”. The
others simply drop to their shell.
To detach without attaching, use detach-client. With -a it detaches every client except the
current one; with -t <client> it detaches one named client (use the name from list-clients).
From the keyboard, prefix D opens choose-client -Z, an interactive picker where you select a
client and press a key to detach it.
One sharper variant: tmux attach -x also sends SIGHUP to the parent process of the client it
detaches. That closes the program that launched tmux, for example the SSH session on the other
side, instead of just dropping it to a shell.
Verified on tmux 3.2a.