wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
16.68k stars 745 forks source link

Close all panes except for the curent one #5321

Open nkhlmn opened 4 months ago

nkhlmn commented 4 months ago

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 commented 4 months ago

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.

wez commented 4 months ago

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.

xMonody commented 3 months ago

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.

chasinglogic commented 2 months ago

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

xMonody commented 2 months ago

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.