wezterm
wezterm copied to clipboard
SpawnTab next to current tab
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.
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?
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.
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.
I am also interested in this.
Is there any workaround to achieve this in the meanwhile?
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
Thank you, I'll take a look!
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),
},
}
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: