Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a key bound to setup panes to my liking, but sometimes things get messed up or out of hand and I want to close all the panes and rerun the script. Is there a simple tmux command to close all panes except the one I am currently in?

share|improve this question
up vote 15 down vote accepted

You can use the "kill-pane" command.

 kill-pane [-a] [-t target-pane]
               (alias: killp)
         Destroy the given pane.  If no panes remain in the containing window, it is also destroyed.  The -a option kills all but the pane given with -t.

So, for example if you want to kill all the panes except for pane 0:

kill-pane -a -t 0

If you don't know what you pane numbers are you can use the "display-panes" command:

 display-panes [-t target-client]
               (alias: displayp)
         Display a visible indicator of each pane shown by target-client.  See the display-panes-time, display-panes-colour, and display-panes-active-colour
         session options.  While the indicator is on screen, a pane may be selected with the '0' to '9' keys.
share|improve this answer
Thanks I did end up using kill-pane but I was having trouble getting it to work all the time. What I ended up doing was spliting the window (split-window-h) that way I could be sure there was more than 1 pane, then I did a (break-pane -d) to move my current frame to a new window in the background. Then I do kill-window. That way I will be in a pane in a new window (the only one). – Digital Powers Jun 22 '11 at 20:26
@DigitalPowers I like your solution, but sometimes it can make the split pane hard to find. Especially if you close a lot of panes. Since I was binding to a key, I used the hacky option of "enough" swap-pane -U commands to move the pane to position 0, and then kill-pane -a -t 0. – Edd Steel Apr 17 '13 at 23:30
Note: tmux kill-pane -a kills all except the current pane. You don't need to specify the -t target if you like the current pane. – The Doctor What May 4 '13 at 0:27

There is also "^b !" according to http://www.dayid.org/os/notes/tm.html (I also tried it and it worked for me)

share|improve this answer
hey! it looks like it works, but what it actually does is move that pane to a new "window" - kind of divorces it from the parent window - so the other panes still exist, they're just in a different window. – Brad Parks Jun 2 '14 at 15:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.