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-pane -a closes every pane except the one you are in

Tmux
~/tips/tip-tmux-kill-other-panes

tmux kill-pane -a

Clears all other panes in the window in one command.

After a debugging session you can end up with five panes and only care about one. Closing them one by one with Ctrl-b x takes a lot of confirming.

tmux kill-pane -a

The -a flag turns the command around: tmux keeps the target pane and kills all the others in that window. Without -t the target is the current pane, so the one you are looking at survives.

You can aim it at another pane too:

tmux kill-pane -a -t 0

That keeps pane 0 and closes the rest. Other windows and sessions are not touched.

Be careful with it, because there is no confirmation and no undo. Whatever ran in those panes is ended, so an editor with unsaved changes or a half finished copy dies with them. I’d only bind it to a key behind confirm-before:

bind X confirm-before -p "kill all other panes? (y/n)" "kill-pane -a"

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