brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: tmux list-clients shows who is attached to which session

Tmux
~/tips/tip-tmux-list-clients

tmux list-clients

Lists every terminal connected to tmux, with session and size.

Is that session still attached somewhere? tmux ls only says “(attached)”. list-clients tells you where.

tmux list-clients

Every line is one connected terminal: its tty, the session it shows, its size and terminal type. With no one attached it prints nothing at all.

Like the other list commands it takes a format, which is easier to read in scripts:

tmux list-clients -F '#{client_tty} #{session_name} #{client_width}x#{client_height}'

And -t limits the list to one session:

tmux list-clients -t work

I’d pair the tty from this list with detach-client -t, which takes a client as its target. That detaches one specific terminal from a script, without the interactive picker.

A client here is a terminal window, not a person. One user with two terminals attached shows up twice, and a stale SSH connection that hasn’t timed out yet still counts as attached until the network gives up on it.

Further reading: tmux manual page (OpenBSD)

More Tmux tips tmux new -d -s report -x 200 -y 50 'top' tmux wait-for build-done set -g allow-passthrough on tmux kill-server Ctrl-b [ All Tmux tips (125) All topics

Link