current
1local wezterm = require("wezterm")
2local module = {}
3
4function module.apply(config)
5 -- 禁用默认键绑定
6 config.disable_default_key_bindings = true
7
8 config.keys = {}
9 local act = wezterm.action
10 -- #===# 常规按键绑定 #===# --
11 -- 复制
12 table.insert(
13 config.keys,
14 { key = "c", mods = "CTRL|SHIFT", action = act.CopyTo("Clipboard") }
15 )
16 table.insert(config.keys, { key = "Copy", action = act.CopyTo("Clipboard") })
17 -- 粘贴
18 table.insert(
19 config.keys,
20 { key = "v", mods = "CTRL|SHIFT", action = act.PasteFrom("Clipboard") }
21 )
22 table.insert(
23 config.keys,
24 { key = "Paste", action = act.PasteFrom("Clipboard") }
25 )
26 -- Lua 配置 Debug 叠加层
27 table.insert(
28 config.keys,
29 { key = "l", mods = "CTRL|SHIFT", action = act.ShowDebugOverlay }
30 )
31 -- 命令面板
32 table.insert(
33 config.keys,
34 { key = "p", mods = "CTRL|SHIFT", action = act.ActivateCommandPalette }
35 )
36 -- 搜索
37 table.insert(
38 config.keys,
39 {
40 key = "f",
41 mods = "CTRL|SHIFT",
42 action = act.Search { CaseSensitiveString = "" },
43 }
44 )
45 -- #===# 标签页按键控制 #===# --
46 -- 新建标签页
47 table.insert(
48 config.keys,
49 { key = "t", mods = "CTRL|ALT", action = act.SpawnTab("CurrentPaneDomain") }
50 )
51 -- 关闭标签页
52 table.insert(
53 config.keys,
54 {
55 key = "q",
56 mods = "CTRL|ALT",
57 action = act.CloseCurrentTab { confirm = true },
58 }
59 )
60 -- 切换标签页
61 for i = 1, 8 do
62 table.insert(
63 config.keys,
64 { key = tostring(i), mods = "CTRL|ALT", action = act.ActivateTab(i - 1) }
65 )
66 end
67 -- 切换相邻标签页
68 table.insert(
69 config.keys,
70 { key = "[", mods = "CTRL|ALT", action = act.ActivateTabRelative(-1) }
71 )
72 table.insert(
73 config.keys,
74 { key = "]", mods = "CTRL|ALT", action = act.ActivateTabRelative(1) }
75 )
76end
77
78return module