wezterm icon indicating copy to clipboard operation
wezterm copied to clipboard

Close all panes except for the curent one

Open nkhlmn opened this issue 10 months ago • 5 comments

Is your feature request related to a problem? Please describe. I would like to close all panes except for the currently active one with a keybinding

Describe the solution you'd like Ideally, a new KeyAssignment function that can be used in a keybinding

Describe alternatives you've considered I've looked into using action_callback and I see how you can get a list of panes for a tab and the currently active one, but it's not clear to me how to close them.

Additional context

nkhlmn avatar Apr 20 '24 23:04 nkhlmn

I was able to figure out how to do this with action_callback. E.g.

  {
    key = 'o',
    mods = 'LEADER|CTRL',
    action = action_callback(function(win, pane)
      local tab = win:active_tab()
      for _, p in ipairs(tab:panes()) do
        if p:pane_id() ~= pane:pane_id() then
          p:activate()
          win:perform_action(action.CloseCurrentPane { confirm = false }, p)
        end
      end
    end),
  },

It would be nice to have this as an available action though. Happy to submit a PR for that if you feel that is a reasonable thing to add.

nkhlmn avatar Apr 20 '24 23:04 nkhlmn

I'd rather wait and see if many others request this feature before adding it into the core; I think scripting your own solution is a reasonable outcome in the meantime.

wez avatar May 05 '24 23:05 wez

I'd rather wait and see if many others request this feature before adding it into the core; I think scripting your own solution is a reasonable outcome in the meantime.

Hello, I really want this shortcut to be integrated. Also, can you add a shortcut to close all tabs except the current one? Thank you for your project.

xMonody avatar May 23 '24 23:05 xMonody

I too was surprised this isn't available and would vote for it to be in the core

chasinglogic avatar Jun 24 '24 08:06 chasinglogic

I too was surprised this isn't available and would vote for it to be in the core

I've sorted out this problem by setting up a configuration.

xMonody avatar Jun 24 '24 10:06 xMonody