Open alfa07 opened 1 year ago
I encountered this same problem when trying to set up a workflow with a temporary tab running lazygit
, where after closing the process I want to return to the previous tab. While waiting for https://github.com/wez/wezterm/pull/5576 to make progress I came up with the following workaround:
local function SpawnCommandInTemporaryTab(args)
return wezterm.action_callback(function(window, pane)
local active_tab_index = 0
for _, tab in ipairs(pane:window():tabs_with_info()) do
if tab.is_active then
active_tab_index = tab.index
end
end
window:perform_action(wezterm.action.SpawnCommandInNewTab(args) , pane)
window:perform_action(wezterm.action.MoveTab(active_tab_index), pane)
end)
end
config.keys = {
{ key = 'g', mods = 'LEADER', action = SpawnCommandInTemporaryTab { args = { 'lazygit' } } },
}
This leverages the fact that the tab index isn't updated when closing tabs (unless it's the last one). After creating the new tab we move it to the current tab's index, so when it closes focus will move back to the original tab.
Is your feature request related to a problem? Please describe. In modal workflows, e.g. opening lazygit in a new tab, committing changes, closing lazygit, I would expect to return to the tab where I've been before.
Describe the solution you'd like Keep tab visiting history and when the current tab is closed pop tab from the history and activate it.
Describe alternatives you've considered I am not sure there are many alternatives
Additional context Here is the shortcut I use to launch lazygit:
when I quit lazygit I expect to return to the tab from which I've launched it (previous in the visiting order).
Another feature which is related is
switch to last tab
something likectrl-^
in vim.