summaryrefslogtreecommitdiff
path: root/dot_config/wezterm/keys.lua
blob: 724840f63e61a2f45b1e948b9984287a7474d223 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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.

		-- 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