21

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?

2 Answers 2

31

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.
3
  • 1
    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). Commented Jun 22, 2011 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.
    – user4137
    Commented Apr 17, 2013 at 23:30
  • 14
    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.
    – docwhat
    Commented May 4, 2013 at 0:27
9

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

1
  • 9
    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
    Commented Jun 2, 2014 at 15:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .