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 kill-session -a closes every session except the one you name

Tmux
~/tips/tip-tmux-kill-session-a

tmux kill-session -a -t work

Kills all tmux sessions apart from the one you keep, for a quick clean-up.

Old sessions pile up on a server, and killing them one by one is tedious.

tmux kill-session -a -t work

The -a flag means ‘all others’, so only work survives. Look at the list first with tmux ls.

The -a flag works the same on other tmux commands such as kill-window -a and kill-pane -a. It is a quick way to get back to a clean state after an afternoon of experiments.

Run tmux ls first and check that nothing in the other sessions is still doing real work, because there is no confirmation prompt. If you only want to close one session, tmux kill-session -t name is the more careful version.

It stops whatever is running in those sessions. If a long job lives in one of them, it ends too.

Try it without risk: start a throwaway session with tmux new -s scratch, use the shortcut or command above there, look at what changes, and close the session again with tmux kill-session -t scratch. Nothing else on your machine is touched.

Further reading: tmux manual page (OpenBSD, official), tmux wiki: Getting Started (official), On this site: tmux new -As work attaches to a session or creates it, On this site: Ctrl-b $ renames the tmux session you are in

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