-
Notifications
You must be signed in to change notification settings - Fork 0
/
wezterm.lua
357 lines (339 loc) · 11.3 KB
/
wezterm.lua
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
local wezterm = require 'wezterm'
local act = wezterm.action
-- -- The filled in variant of the < symbol
-- local SOLID_LEFT_ARROW = utf8.char(0xe0b2)
-- -- The filled in variant of the > symbol
-- local SOLID_RIGHT_ARROW = utf8.char(0xe0b0)
--
-- wezterm.on(
-- 'format-tab-title',
-- function(tab, tabs, panes, config, hover, max_width)
-- local edge_background = '#0b0022'
-- local background = '#1b1032'
-- local foreground = '#808080'
--
-- if tab.is_active then
-- background = '#2b2042'
-- foreground = '#c0c0c0'
-- elseif hover then
-- background = '#3b3052'
-- foreground = '#909090'
-- end
--
-- local edge_foreground = background
--
-- -- ensure that the titles fit in the available space,
-- -- and that we have room for the edges.
-- local title = wezterm.truncate_right(tab.active_pane.title, max_width - 2)
--
-- return {
-- { Background = { Color = edge_background } },
-- { Foreground = { Color = edge_foreground } },
-- { Text = SOLID_LEFT_ARROW },
-- { Background = { Color = background } },
-- { Foreground = { Color = foreground } },
-- { Text = title },
-- { Background = { Color = edge_background } },
-- { Foreground = { Color = edge_foreground } },
-- { Text = SOLID_RIGHT_ARROW },
-- }
-- end
-- )
local original_copy_mode = {
{
key = 'Tab',
mods = 'NONE',
action = act.CopyMode 'MoveForwardWord',
},
{
key = 'Tab',
mods = 'SHIFT',
action = act.CopyMode 'MoveBackwardWord',
},
{
key = 'Enter',
mods = 'NONE',
action = act.CopyMode 'MoveToStartOfNextLine',
},
{ key = 'Escape', mods = 'NONE', action = act.CopyMode 'Close' },
{
key = 'Space',
mods = 'NONE',
action = act.CopyMode { SetSelectionMode = 'Cell' },
},
{
key = '$',
mods = 'NONE',
action = act.CopyMode 'MoveToEndOfLineContent',
},
{
key = '$',
mods = 'SHIFT',
action = act.CopyMode 'MoveToEndOfLineContent',
},
{
key = '0',
mods = 'NONE',
action = act.CopyMode 'MoveToStartOfLine',
},
{
key = 'G',
mods = 'NONE',
action = act.CopyMode 'MoveToScrollbackBottom',
},
{
key = 'G',
mods = 'SHIFT',
action = act.CopyMode 'MoveToScrollbackBottom',
},
{
key = 'H',
mods = 'NONE',
action = act.CopyMode 'MoveToViewportTop',
},
{
key = 'H',
mods = 'SHIFT',
action = act.CopyMode 'MoveToViewportTop',
},
{
key = 'L',
mods = 'NONE',
action = act.CopyMode 'MoveToViewportBottom',
},
{
key = 'L',
mods = 'SHIFT',
action = act.CopyMode 'MoveToViewportBottom',
},
{
key = 'M',
mods = 'NONE',
action = act.CopyMode 'MoveToViewportMiddle',
},
{
key = 'M',
mods = 'SHIFT',
action = act.CopyMode 'MoveToViewportMiddle',
},
{
key = 'O',
mods = 'NONE',
action = act.CopyMode 'MoveToSelectionOtherEndHoriz',
},
{
key = 'O',
mods = 'SHIFT',
action = act.CopyMode 'MoveToSelectionOtherEndHoriz',
},
{
key = 'V',
mods = 'NONE',
action = act.CopyMode { SetSelectionMode = 'Line' },
},
{
key = 'V',
mods = 'SHIFT',
action = act.CopyMode { SetSelectionMode = 'Line' },
},
{
key = '^',
mods = 'NONE',
action = act.CopyMode 'MoveToStartOfLineContent',
},
{
key = '^',
mods = 'SHIFT',
action = act.CopyMode 'MoveToStartOfLineContent',
},
{ key = 'b', mods = 'NONE', action = act.CopyMode 'MoveBackwardWord' },
{ key = 'b', mods = 'ALT', action = act.CopyMode 'MoveBackwardWord' },
{ key = 'b', mods = 'CTRL', action = act.CopyMode 'PageUp' },
{ key = 'c', mods = 'CTRL', action = act.CopyMode 'Close' },
{ key = 'f', mods = 'ALT', action = act.CopyMode 'MoveForwardWord' },
{ key = 'f', mods = 'CTRL', action = act.CopyMode 'PageDown' },
{
key = 'g',
mods = 'NONE',
action = act.CopyMode 'MoveToScrollbackTop',
},
{ key = 'g', mods = 'CTRL', action = act.CopyMode 'Close' },
{ key = 'h', mods = 'NONE', action = act.CopyMode 'MoveLeft' },
{ key = 'j', mods = 'NONE', action = act.CopyMode 'MoveDown' },
{ key = 'k', mods = 'NONE', action = act.CopyMode 'MoveUp' },
{ key = 'l', mods = 'NONE', action = act.CopyMode 'MoveRight' },
{
key = 'm',
mods = 'ALT',
action = act.CopyMode 'MoveToStartOfLineContent',
},
{
key = 'o',
mods = 'NONE',
action = act.CopyMode 'MoveToSelectionOtherEnd',
},
{ key = 'q', mods = 'NONE', action = act.CopyMode 'Close' },
{
key = 'v',
mods = 'NONE',
action = act.CopyMode { SetSelectionMode = 'Cell' },
},
{
key = 'v',
mods = 'CTRL',
action = act.CopyMode { SetSelectionMode = 'Block' },
},
{ key = 'w', mods = 'NONE', action = act.CopyMode 'MoveForwardWord' },
{
key = 'y',
mods = 'NONE',
action = act.Multiple {
{ CopyTo = 'ClipboardAndPrimarySelection' },
{ CopyMode = 'Close' },
},
},
{ key = 'PageUp', mods = 'NONE', action = act.CopyMode 'PageUp' },
{ key = 'PageDown', mods = 'NONE', action = act.CopyMode 'PageDown' },
{ key = 'u', mods = 'CTRL', action = act.CopyMode 'PageUp' },
{ key = 'd', mods = 'CTRL', action = act.CopyMode 'PageDown' },
{ key = 'LeftArrow', mods = 'NONE', action = act.CopyMode 'MoveLeft' },
{
key = 'LeftArrow',
mods = 'ALT',
action = act.CopyMode 'MoveBackwardWord',
},
{
key = 'RightArrow',
mods = 'NONE',
action = act.CopyMode 'MoveRight',
},
{
key = 'RightArrow',
mods = 'ALT',
action = act.CopyMode 'MoveForwardWord',
},
{ key = 'UpArrow', mods = 'NONE', action = act.CopyMode 'MoveUp' },
{ key = 'DownArrow', mods = 'NONE', action = act.CopyMode 'MoveDown' },
}
-- My customization
custom_copy_mode = original_copy_mode
table.insert(
custom_copy_mode,
{ key = 'u', mods = 'CTRL', action = act.CopyMode 'PageUp' }
)
table.insert(
custom_copy_mode,
{ key = 'd', mods = 'CTRL', action = act.CopyMode 'PageDown' }
)
return {
-- Font configs
font = wezterm.font {
family = 'Hack Nerd Font',
},
font_size = 11.0,
-- System configs
check_for_updates = false,
animation_fps = 1,
cursor_blink_ease_in = 'Constant',
cursor_blink_ease_out = 'Constant',
cursor_blink_rate = 0,
native_macos_fullscreen_mode = true,
window_padding = {
left = 0,
right = 0,
top = 0,
bottom = 0,
},
scrollback_lines = 9001,
-- Tab bar style
tab_bar_at_bottom = true,
hide_tab_bar_if_only_one_tab = true,
leader = {
-- key = 'b',
key = 'a',
mods = 'CTRL',
timeout_milliseconds = 1000,
},
key_tables = {
-- We cannot override the original copy_mode table
-- so copy paste from default setting and then add our own
copy_mode = custom_copy_mode,
},
keys = {
-- Send 'CTRL-b' to the terminal when pressing CTRL-b, CTRL-b
-- { key = 'b', mods = 'LEADER|CTRL', action = act.SendString '\x02' },
{ key = 'a', mods = 'LEADER|CTRL', action = act.SendString '\x01' },
{ key = 'f', mods = 'CMD|CTRL', action = act.ToggleFullScreen },
{
key="e", mods="CTRL|SHIFT",
action=act{QuickSelectArgs={
patterns={
"https?://\\S+"
},
action = wezterm.action_callback(
function(window, pane)
local url = window:get_selection_text_for_pane(pane)
wezterm.log_info("opening: " .. url)
wezterm.open_with(url)
end
)
}}
},
-- **Copy Mode**
{ key = '[', mods = 'LEADER', action = act.ActivateCopyMode },
-- **Screen management**
{ key = 'c', mods = 'LEADER', action = act.SpawnTab 'CurrentPaneDomain' },
{ key = 'p', mods = 'LEADER', action = act.ActivateTabRelative(-1) },
{ key = 'n', mods = 'LEADER', action = act.ActivateTabRelative(1) },
{ key = 'o', mods = 'LEADER', action = act.ActivatePaneDirection 'Next' },
{ key = 'l', mods = 'LEADER', action = act.SplitHorizontal {domain = 'CurrentPaneDomain'} },
{ key = 'j', mods = 'LEADER', action = act.SplitVertical {domain = 'CurrentPaneDomain'} },
-- Quick open http links using Ctrl + Shift + E
{
key="e", mods="CTRL|SHIFT",
action=act{QuickSelectArgs={
patterns={
"https?://\\S+"
},
action = wezterm.action_callback(function(window, pane)
local url = window:get_selection_text_for_pane(pane)
wezterm.log_info("opening: " .. url)
wezterm.open_with(url)
end)
}}
},
-- Close current pane
{key = 'w', mods = 'CMD', action = act.CloseCurrentPane { confirm = true } },
-- **Editor/Shell navigations**
{ key = 'a', mods = 'SUPER', action = act{SendString = '\x1ba'} },
{ key = 'b', mods = 'SUPER', action = act{SendString = '\x1bb'} },
-- leave CMD + C for copy
-- { key = 'c', mods = 'SUPER', action = act{SendString = '\x1bc'} },
{ key = 'd', mods = 'SUPER', action = act{SendString = '\x1bd'} },
{ key = 'e', mods = 'SUPER', action = act{SendString = '\x1be'} },
-- { key = 'f', mods = 'SUPER', action = act{SendString = '\x1bf'} },
{ key = 'g', mods = 'SUPER', action = act{SendString = '\x1bg'} },
{ key = 'h', mods = 'SUPER', action = act{SendString = '\x1bh'} },
{ key = 'i', mods = 'SUPER', action = act{SendString = '\x1bi'} },
{ key = 'j', mods = 'SUPER', action = act{SendString = '\x1bj'} },
{ key = 'k', mods = 'SUPER', action = act{SendString = '\x1bk'} },
{ key = 'l', mods = 'SUPER', action = act{SendString = '\x1bl'} },
{ key = 'm', mods = 'SUPER', action = act{SendString = '\x1bm'} },
{ key = 'n', mods = 'SUPER', action = act{SendString = '\x1bn'} },
{ key = 'o', mods = 'SUPER', action = act{SendString = '\x1bo'} },
{ key = 'p', mods = 'SUPER', action = act{SendString = '\x1bp'} },
-- leave CMD + Q for close app
-- { key = 'q', mods = 'SUPER', action = act{SendString = '\x1bq'} },
{ key = 'r', mods = 'SUPER', action = act{SendString = '\x1br'} },
{ key = 's', mods = 'SUPER', action = act{SendString = '\x1bs'} },
{ key = 't', mods = 'SUPER', action = act{SendString = '\x1bt'} },
{ key = 'u', mods = 'SUPER', action = act{SendString = '\x1bu'} },
-- leave CMD + V for paste
-- { key = 'v', mods = 'SUPER', action = act{SendString = '\x1bv'} },
-- leave CMD + W for close tab
-- { key = 'w', mods = 'SUPER', action = act{SendString = '\x1bw'} },
{ key = 'x', mods = 'SUPER', action = act{SendString = '\x1bx'} },
{ key = 'y', mods = 'SUPER', action = act{SendString = '\x1by'} },
{ key = 'z', mods = 'SUPER', action = act{SendString = '\x1bz'} },
},
}