From e9473cb543ee2a7e38ddf6aa953998efcfd290e2 Mon Sep 17 00:00:00 2001 From: Kevin Silvester Date: Fri, 11 Oct 2024 17:33:53 +0100 Subject: [PATCH] feat: add key-binding to toggle tabbar + remove print statement --- README.md | 6 ++++++ config/bindings.lua | 7 +++++-- events/tab-title.lua | 14 +++++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3e564af..c4b3c19 100644 --- a/README.md +++ b/README.md @@ -283,6 +283,12 @@ Most of the key bindings revolve around a SUPER and SUPER_REVSUPER+9 | Toggle tab bar | + +##### Tabs: Toggle Tab-bar + | Keys | Action | | --------------------------------- | ------------------ | | SUPER+0 | Rename Current Tab | diff --git a/config/bindings.lua b/config/bindings.lua index 42185dc..eda8227 100644 --- a/config/bindings.lua +++ b/config/bindings.lua @@ -70,8 +70,11 @@ local keys = { { key = ']', mods = mod.SUPER_REV, action = act.MoveTabRelative(1) }, -- tab: title - { key = '0', mods = mod.SUPER, action = act.EmitEvent('manual-update-tab-title') }, - { key = '0', mods = mod.SUPER_REV, action = act.EmitEvent('reset-tab-title') }, + { key = '0', mods = mod.SUPER, action = act.EmitEvent('tabs.manual-update-tab-title') }, + { key = '0', mods = mod.SUPER_REV, action = act.EmitEvent('tabs.reset-tab-title') }, + + -- tab: hide tab-bar + { key = '9', mods = mod.SUPER, action = act.EmitEvent('tabs.toggle-tab-bar'), }, -- window -- -- spawn windows diff --git a/events/tab-title.lua b/events/tab-title.lua index 371f17e..6cfc3eb 100644 --- a/events/tab-title.lua +++ b/events/tab-title.lua @@ -184,10 +184,12 @@ end local tab_list = {} M.setup = function() + wezterm.GLOBAL.enable_tab_bar = true + -- CUSTOM EVENT -- Event listener to manually update the tab name -- Tab name will remain locked until the `reset-tab-title` is triggered - wezterm.on('manual-update-tab-title', function(window, pane) + wezterm.on('tabs.manual-update-tab-title', function(window, pane) window:perform_action( wezterm.action.PromptInputLine({ description = wezterm.format({ @@ -209,15 +211,21 @@ M.setup = function() -- CUSTOM EVENT -- Event listener to unlock manually set tab name - wezterm.on('reset-tab-title', function(window, _pane) + wezterm.on('tabs.reset-tab-title', function(window, _pane) local tab = window:active_tab() local id = tab:tab_id() tab_list[id].title_locked = false end) + -- CUSTOM EVENT + -- Event listener to manually update the tab name + wezterm.on('tabs.toggle-tab-bar', function(window, _pane) + wezterm.GLOBAL.enable_tab_bar = not wezterm.GLOBAL.enable_tab_bar + window:set_config_overrides({ enable_tab_bar = wezterm.GLOBAL.enable_tab_bar }) + end) + -- BUILTIN EVENT wezterm.on('format-tab-title', function(tab, _tabs, _panes, _config, hover, max_width) - print(tab_list) if not tab_list[tab.tab_id] then tab_list[tab.tab_id] = Tab:new() tab_list[tab.tab_id]:set_info(tab.active_pane, max_width)