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
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.
-
1Thanks 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 -Ucommands to move the pane to position 0, and thenkill-pane -a -t 0.– user4137Commented Apr 17, 2013 at 23:30 -
15Note:
tmux kill-pane -akills all except the current pane. You don't need to specify the-ttarget if you like the current pane.– docwhatCommented May 4, 2013 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)
-
9hey! 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. Commented Jun 2, 2014 at 15:36