wezterm: Allow toggling tab bar display

Tab display can be toggled on or off with `Ctrl+Shift+T`. The toggling
takes place per-window and not globally, so we can have a wezterm
terminal on desktop 1 with a tabbar and on desktop 2 without. Opening
a new terminal always defaults to an enabled tab bar.
This commit is contained in:
Marty Oehme 2024-02-16 11:01:41 +01:00
parent 0c7ad09789
commit ab123a4c36
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
3 changed files with 16 additions and 2 deletions

View file

@ -67,15 +67,27 @@ local function setup()
wezterm.log_info("toggling the leader") wezterm.log_info("toggling the leader")
local overrides = window:get_config_overrides() or {} local overrides = window:get_config_overrides() or {}
if not overrides.leader then if not overrides.leader then
wezterm.log_info("leader wasn't set") wezterm.log_info("enabling leader key")
overrides.leader = { key = "s", mods = "SUPER" } overrides.leader = { key = "s", mods = "SUPER" }
else else
wezterm.log_info("leader was set") wezterm.log_info("disabling leader key")
overrides.leader = nil overrides.leader = nil
end end
window:set_config_overrides(overrides) window:set_config_overrides(overrides)
end) end)
wezterm.on("toggle-tabbar", function(window, _)
local overrides = window:get_config_overrides() or {}
if overrides.enable_tab_bar == false then
wezterm.log_info("showing tab bar")
overrides.enable_tab_bar = true
else
wezterm.log_info("hiding tab bar")
overrides.enable_tab_bar = false
end
window:set_config_overrides(overrides)
end)
end end
return { setup = setup } return { setup = setup }

View file

@ -100,6 +100,7 @@ local keys = {
action = act.EmitEvent("ActivatePaneDirection-Right"), action = act.EmitEvent("ActivatePaneDirection-Right"),
}, },
{ key = "a", mods = "CTRL|ALT", action = act.EmitEvent("toggle-leader") }, { key = "a", mods = "CTRL|ALT", action = act.EmitEvent("toggle-leader") },
{ key = "T", mods = "CTRL", action = act.EmitEvent("toggle-tabbar") },
} }
-- Leader + number to activate that tab -- Leader + number to activate that tab
for i = 1, 8 do for i = 1, 8 do

View file

@ -25,6 +25,7 @@ end
local settings = { local settings = {
enable_wayland = true, enable_wayland = true,
enable_tab_bar = true,
hide_tab_bar_if_only_one_tab = true, hide_tab_bar_if_only_one_tab = true,
use_fancy_tab_bar = false, use_fancy_tab_bar = false,
tab_bar_at_bottom = true, tab_bar_at_bottom = true,