From be938fafe4a09ea4f74f6cb3efb5c4046ede30bc Mon Sep 17 00:00:00 2001 From: Ibrahim Muftee Date: Thu, 3 Oct 2024 17:41:43 -0500 Subject: feat(wezterm): add keybindings for tabs and panes --- dot_config/wezterm/keys.lua | 82 ++++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 30 deletions(-) (limited to 'dot_config/wezterm/keys.lua') diff --git a/dot_config/wezterm/keys.lua b/dot_config/wezterm/keys.lua index 22889da..724840f 100644 --- a/dot_config/wezterm/keys.lua +++ b/dot_config/wezterm/keys.lua @@ -1,36 +1,58 @@ local wezterm = require("wezterm") local M = { - leader = { key = "t", mods = "CTRL", timeout_milliseconds = 500 }, - key_bindings = { - -- Leader commands - -- Ctrl+t (for "terminal" is my leader key for Wezterm, and it's the gateway - -- into all my most-used terminal commands. - -- By avoiding the single keystroke Ctrl+t in my Vim config, I can prevent - -- key conflicts between Vim and Wezterm. - - -- Pane splitting - { key = "s", mods = "LEADER|CTRL", action = wezterm.action.SplitHorizontal }, - { key = "v", mods = "LEADER|CTRL|SHIFT", action = wezterm.action.SplitVertical }, - - -- Clipboard actions - { key = "v", mods = "LEADER|CTRL", action = wezterm.action.PasteFrom("Clipboard") }, - { key = "x", mods = "LEADER|CTRL", action = wezterm.action.ActivateCopyMode }, - - -- Fallback - use Ctrl-T, Ctrl-Shift-T to send a literal "Ctrl-T" to the console - { key = "t", mods = "LEADER|CTRL|SHIFT", action = wezterm.action.SendKey({ key = "t", mods = "CTRL" }) }, - - -- Ctrl+h/j/k/l is for Vim, so use C+A+h/j/k/l to move between - -- panes in the terminal - { key = "h", mods = "CTRL|ALT", action = { ActivatePaneDirection = "Left" } }, - { key = "j", mods = "CTRL|ALT", action = { ActivatePaneDirection = "Down" } }, - { key = "k", mods = "CTRL|ALT", action = { ActivatePaneDirection = "Up" } }, - { key = "l", mods = "CTRL|ALT", action = { ActivatePaneDirection = "Right" } }, - - -- Reload config - { key = "r", mods = "LEADER|CTRL|SHIFT", action = wezterm.action.ReloadConfiguration }, - - }, + leader = { key = "t", mods = "CTRL", timeout_milliseconds = 500 }, + key_bindings = { + -- Leader commands + -- Ctrl+t (for "terminal" is my leader key for Wezterm, and it's the gateway + -- into all my most-used terminal commands. + -- By avoiding the single keystroke Ctrl+t in my Vim config, I can prevent + -- key conflicts between Vim and Wezterm. + + -- Window controls + { key = "n", mods = "LEADER", action = wezterm.action.SpawnWindow }, + + -- Tab controls + { key = "t", mods = "LEADER|CTRL", action = wezterm.action.SpawnTab("CurrentPaneDomain") }, + + { key = "1", mods = "LEADER", action = wezterm.action.ActivateTab(0) }, + { key = "2", mods = "LEADER", action = wezterm.action.ActivateTab(1) }, + { key = "3", mods = "LEADER", action = wezterm.action.ActivateTab(2) }, + { key = "4", mods = "LEADER", action = wezterm.action.ActivateTab(3) }, + { key = "5", mods = "LEADER", action = wezterm.action.ActivateTab(4) }, + { key = "6", mods = "LEADER", action = wezterm.action.ActivateTab(5) }, + + { key = "l", mods = "LEADER", action = wezterm.action.ActivateTabRelative(1) }, + { key = "h", mods = "LEADER", action = wezterm.action.ActivateTabRelative(-1) }, + + { key = "w", mods = "LEADER", action = wezterm.action.CloseCurrentTab({ confirm = true }) }, + + -- Pane controls + { key = "s", mods = "LEADER", action = wezterm.action.SplitHorizontal }, + { key = "v", mods = "LEADER", action = wezterm.action.SplitVertical }, + { key = "c", mods = "LEADER", action = wezterm.action.CloseCurrentPane({ confirm = false }) }, + + -- Clipboard actions + { key = "v", mods = "LEADER|CTRL", action = wezterm.action.PasteFrom("Clipboard") }, + { key = "x", mods = "LEADER|CTRL", action = wezterm.action.ActivateCopyMode }, + + -- Fallback - use Ctrl-T, Ctrl-Shift-T to send a literal "Ctrl-T" to the console + { key = "t", mods = "LEADER|CTRL|SHIFT", action = wezterm.action.SendKey({ key = "t", mods = "CTRL" }) }, + + -- Ctrl+h/j/k/l is for Vim, so use C+A+h/j/k/l to move between + -- panes in the terminal + { key = "h", mods = "CTRL|ALT", action = { ActivatePaneDirection = "Left" } }, + { key = "j", mods = "CTRL|ALT", action = { ActivatePaneDirection = "Down" } }, + { key = "k", mods = "CTRL|ALT", action = { ActivatePaneDirection = "Up" } }, + { key = "l", mods = "CTRL|ALT", action = { ActivatePaneDirection = "Right" } }, + + -- Reload config + { key = "r", mods = "LEADER|CTRL|SHIFT", action = wezterm.action.ReloadConfiguration }, + + -- Move the config overlay to different keymap (Ctrl-Shift-L used by Tmux) + { key = "L", mods = "CTRL", action = wezterm.action.DisableDefaultAssignment }, + { key = "l", mods = "LEADER|CTRL|SHIFT", action = wezterm.action.ShowDebugOverlay }, + }, } return M -- cgit v1.2.3