Skip to content

Commit

Permalink
feat: add key-binding to toggle tabbar + remove print statement
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinSilvester committed Oct 11, 2024
1 parent 7349ad5 commit e9473cb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ Most of the key bindings revolve around a <kbd>SUPER</kbd> and <kbd>SUPER_REV</k

##### Tabs: Title

| Keys | Action |
| ------------------------------| -------------- |
| <kbd>SUPER</kbd>+<kbd>9</kbd> | Toggle tab bar |

##### Tabs: Toggle Tab-bar

| Keys | Action |
| --------------------------------- | ------------------ |
| <kbd>SUPER</kbd>+<kbd>0</kbd> | Rename Current Tab |
Expand Down
7 changes: 5 additions & 2 deletions config/bindings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions events/tab-title.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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)
Expand Down

0 comments on commit e9473cb

Please sign in to comment.