wezterm: Added toggling ability for leader key

Sometimes the leader key gets in the way. Since my leader key
combination is C-a by default, this interferes with the (rare) times
that I want to increment something in vim (also C-a).

So, this commit allows toggling the leader key in wezterm off, so it
passes through to the actual applications. You can toggle it with
`C-Alt-a`.

Commit made possible with the help of the comments in this issue:
https://github.com/wez/wezterm/issues/656
This commit is contained in:
Marty Oehme 2022-12-20 23:11:03 +01:00
parent 2e6c1026fb
commit 205c48633f
Signed by: Marty
GPG Key ID: 73BA40D5AFAF49C9
2 changed files with 17 additions and 2 deletions

View File

@ -58,6 +58,20 @@ local function setup()
wezterm.sleep_ms(1000)
os.remove(name)
end)
wezterm.on("toggle-leader", function(window, pane)
wezterm.log_info("toggling the leader")
local overrides = window:get_config_overrides() or {}
if not overrides.leader then
wezterm.log_info("leader wasn't set")
overrides.leader = { key = "s", mods = "SUPER" };
else
wezterm.log_info("leader was set")
overrides.leader = nil
end
window:set_config_overrides(overrides)
end)
end
return { setup = setup }

View File

@ -73,7 +73,8 @@ local keys = {
key = 'l',
mods = 'LEADER',
action = act.EmitEvent 'ActivatePaneDirection-Right'
}
},
{ key = 'a', mods = 'CTRL|ALT', action = act.EmitEvent 'toggle-leader'}
}
-- Leader + number to activate that tab
@ -108,6 +109,6 @@ local key_tables = {
{ key = 'g', mods = 'CTRL', action = act.ScrollToTop },
{ key = 'G', mods = 'CTRL', action = act.ScrollToBottom },
{ key = 'Escape', action = 'PopKeyTable' }
}
},
}
return { keys = keys, key_tables = key_tables }