wezterm icon indicating copy to clipboard operation
wezterm copied to clipboard

SpawnTab next to current tab

Open sekirocc opened this issue 3 years ago • 9 comments

Hi, thanks for you project. Is there any configuration for the feature: Spawm new tab next to current tab. I walked through the docs but didn't find a way to do that.

sekirocc avatar Jun 28 '21 03:06 sekirocc

To clarify: you want to spawn a new tab, but instead of having it get added to the right-hand end of the set of tabs, add it immediately to the right of the current tab?

wez avatar Jun 28 '21 05:06 wez

To clarify: you want to spawn a new tab, but instead of having it get added to the right-hand end of the set of tabs, add it immediately to the right of the current tab?

yes exactly.

sekirocc avatar Jun 28 '21 07:06 sekirocc

Extending SpawnTab with options similar to MoveTab and/or MoveTabRelative seems like the direction to go, but I'll think on it a bit more.

wez avatar Jun 28 '21 15:06 wez

I am also interested in this.

SuperSandro2000 avatar Apr 06 '22 11:04 SuperSandro2000

Is there any workaround to achieve this in the meanwhile?

jgonera avatar Jul 20 '23 23:07 jgonera

I think you can script this for yourself. Look at:

  • https://wezfurlong.org/wezterm/config/lua/wezterm/action_callback.html - to perform multiple actions in a keybind
  • https://wezfurlong.org/wezterm/config/lua/window/mux_window.html - to get the mux window from the gui window
  • https://wezfurlong.org/wezterm/config/lua/mux-window/tabs_with_info.html - to figure out the active tab index
  • https://wezfurlong.org/wezterm/config/lua/mux-window/spawn_tab.html - to synchronously spawn a new tab and return it
  • https://wezfurlong.org/wezterm/config/lua/window/perform_action.html so that you can use https://wezfurlong.org/wezterm/config/lua/keyassignment/MoveTab.html and pass in the desired tab index based on the one you got earlier

wez avatar Jul 20 '23 23:07 wez

Thank you, I'll take a look!

jgonera avatar Jul 20 '23 23:07 jgonera

function active_tab_idx(mux_win)
   for _, item in ipairs(mux_win:tabs_with_info()) do
      -- wezterm.log_info('idx: ', idx, 'tab:', item)
      if item.is_active then
         return item.index
      end
   end
end

-- https://wezfurlong.org/wezterm/config/keys.html
config.keys = {
   {
      key = 't',
      mods = 'CTRL|SHIFT',
      -- https://github.com/wez/wezterm/issues/909
      action = wezterm.action_callback(function(win, pane)
        local mux_win = win:mux_window()
        local idx = active_tab_idx(mux_win)
        -- wezterm.log_info('active_tab_idx: ', idx)
        local tab = mux_win:spawn_tab({})
        -- wezterm.log_info('movetab: ', idx)
        win:perform_action(wezterm.action.MoveTab(idx+1), pane)
      end),
    },
}

MartinNowak avatar Sep 28 '23 09:09 MartinNowak

Just want to mention, i come from konsole (the console for KDE), i use it for a long time, it is very stable and feature rich, i almost use all feature it provided, i use many terminal, it should be pretty good in all of this, the reason i switch to use wezterm is it's still not support OSC52 which discussing for 7 years.

Of course, it can't compete with wezterm, wezterm's kill feature is allow adjust configuration settings on runtime dynamically. the only really useful thing which behind konsole is, it not support puts new tab after current tab out of box! :smile:

image

zw963 avatar Feb 04 '24 11:02 zw963