To kill all tmux sessions, use tmux kill-server
. If you want to kill all sessions except the current one, use tmux kill-session -a
.
$ tmux kill-server
tmux organizes your terminal sessions hierarchically. When you need to clean up and remove all sessions at once, there are several approaches you can take depending on your specific needs.
The most direct way to kill all tmux sessions is to terminate the entire tmux server:
$ tmux kill-server
This command immediately terminates the tmux server along with all running sessions, windows, and panes. Use this with caution as you'll lose all unsaved work in any applications running inside tmux.
If you're already attached to a tmux session and want to keep only that one while terminating all others:
$ tmux kill-session -a
To kill all sessions except a named session (e.g., "dev"):
$ tmux kill-session -a -t dev
If you prefer a more selective approach, you can list all sessions and then kill them using shell scripting:
$ for session in $(tmux list-sessions -F '#{session_name}'); do tmux kill-session -t "$session" done
Killing all tmux sessions will terminate all running programs within those sessions. Make sure to save your work and close applications properly before using these commands.
If you frequently need to manage sessions, consider adding custom key bindings to your .tmux.conf
:
# Kill all other sessions bind X confirm-before -p "kill other sessions? (y/n)" "kill-session -a"