如何关闭 tmux 中除当前窗格之外的所有窗格

Dig*_*ers 19 keyboard-shortcuts tmux

我有一个键可以根据我的喜好设置窗格,但有时事情会变得一团糟或失控,我想关闭所有窗格并重新运行脚本。是否有一个简单的tmux命令可以关闭除我当前所在的窗格之外的所有窗格?

J.C*_*ski 29

您可以使用“kill-pane”命令。

 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.
Run Code Online (Sandbox Code Playgroud)

因此,例如,如果您想杀死除窗格 0 之外的所有窗格:

kill-pane -a -t 0
Run Code Online (Sandbox Code Playgroud)

如果您不知道您的窗格编号是多少,您可以使用“display-panes”命令:

 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.
Run Code Online (Sandbox Code Playgroud)

  • 注意:`tmux kill-pane -a` 会杀死除当前窗格之外的所有窗格。如果您喜欢当前窗格,则无需指定 `-t` 目标。 (11认同)

小智 8

还有“^b!” 根据http://www.dayid.org/os/notes/tm.html(我也尝试过,它对我有用)

  • 嘿!看起来它可以工作,但它实际所做的是将该窗格移动到一个新的“窗口”——有点将它与父窗口分离——所以其他窗格仍然存在,它们只是在不同的窗口中。 (7认同)