-
Notifications
You must be signed in to change notification settings - Fork 0
/
wezterm.lua
185 lines (157 loc) · 5.25 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
local wezterm = require("wezterm")
local act = wezterm.action
local key_tables = {
new_pane = {
{ key = 'h', action = act.SplitHorizontal { args = { 'zsh' } } },
{ key = 'l', action = act.SplitHorizontal { args = { 'zsh' } } },
{ key = 'k', action = act.SplitVertical { args = { 'zsh' } } },
{ key = 'j', action = act.SplitVertical { args = { 'zsh' } } },
-- Cancel the mode by pressing escape
{ key = 'Escape', action = 'PopKeyTable' },
},
resize_pane = {
{ key = 'h', action = act.AdjustPaneSize { 'Left', 1 } },
{ key = 'l', action = act.AdjustPaneSize { 'Right', 1 } },
{ key = 'k', action = act.AdjustPaneSize { 'Up', 1 } },
{ key = 'j', action = act.AdjustPaneSize { 'Down', 1 } },
-- Cancel the mode by pressing escape
{ key = 'Escape', action = 'PopKeyTable' },
},
}
local keys = {
{
key = 'n', mods = 'LEADER', action = act.ActivateKeyTable {
name = 'new_pane',
one_shot = false,
},
},
{
key = 'r', mods = 'LEADER', action = act.ActivateKeyTable {
name = 'resize_pane',
one_shot = false,
},
},
{ key = 'h', mods = 'LEADER', action = act.ActivatePaneDirection 'Left' },
{ key = 'l', mods = 'LEADER', action = act.ActivatePaneDirection 'Right' },
{ key = 'k', mods = 'LEADER', action = act.ActivatePaneDirection 'Up' },
{ key = 'j', mods = 'LEADER', action = act.ActivatePaneDirection 'Down' },
{ key = 'w', mods = 'LEADER', action = act.CloseCurrentPane { confirm = true }, },
{
key = 'c',
mods = 'LEADER',
action = act.ClearScrollback 'ScrollbackOnly',
},
{
key = 's',
mods = 'LEADER',
action = act.PaneSelect {},
},
{
key = 'Space',
mods = 'LEADER',
action = act.QuickSelectArgs {},
},
}
-- Reassign tab to ALT <tab_num>
for i = 1, 8 do
-- ALT + number to activate that tab
table.insert(keys, {
key = tostring(i),
mods = 'ALT',
action = act.ActivateTab(i - 1),
})
end
wezterm.on('update-right-status', function(window, pane)
-- "Wed Mar 3 08:14"
local date = wezterm.strftime '%a %b %-d %H:%M '
local leader = ''
local bat = ''
-- Display battery status on right-status
for _, b in ipairs(wezterm.battery_info()) do
bat = '🔋 ' .. string.format('%.0f%%', b.state_of_charge * 100)
end
-- Display "LEADER" on right-status when pressed leader key
if window:leader_is_active() then
leader = 'LEADER'
end
window:set_right_status(wezterm.format {
{ Text = leader .. ' ' .. bat .. ' ' .. wezterm.nerdfonts.md_clock_outline .. ' ' .. date },
})
end)
-- System notification when reload config(FIXME won't auto dispear)
-- wezterm.on('window-config-reloaded', function(window, pane)
-- window:toast_notification('wezterm', 'configuration reloaded', nil, 1000)
-- end)
-- Disable because too many noise
-- wezterm.on('bell', function(window, pane)
-- window:toast_notification('wezterm', 'Bell at Pane@' .. pane:pane_id(), nil, 1000)
-- end)
return {
leader = { key = 'k', mods = 'CTRL' },
keys = keys,
key_tables = key_tables,
-- After pressed leader key, the cursor will become orange
colors = {
compose_cursor = 'orange',
},
color_scheme = "Galaxy",
font_size = 11.5,
font = wezterm.font_with_fallback {
'JetBrainsMono NF',
'JetBrains Mono',
'Apple Color Emoji',
'Noto Sans CJK SC',
},
warn_about_missing_glyphs = false,
quick_select_patterns = {
-- match things that look like sha1 hashes
-- (this is actually one of the default patterns)
'[0-9a-f]{7,40}',
},
audible_bell = "SystemBeep",
window_background_opacity = 0.95,
text_background_opacity = 1.0,
enable_scroll_bar = true,
scrollback_lines = 10000,
hyperlink_rules = {
-- Linkify things that look like URLs and the host has a TLD name.
-- Compiled-in default. Used if you don't specify any hyperlink_rules.
{
regex = '\\b\\w+://[\\w.-]+\\.[a-z]{2,15}\\S*\\b',
format = '$0',
},
-- linkify email addresses
-- Compiled-in default. Used if you don't specify any hyperlink_rules.
{
regex = [[\b\w+@[\w-]+(\.[\w-]+)+\b]],
format = 'mailto:$0',
},
-- file:// URI
-- Compiled-in default. Used if you don't specify any hyperlink_rules.
{
regex = [[\bfile://\S*\b]],
format = '$0',
},
-- Linkify things that look like URLs with numeric addresses as hosts.
-- E.g. http://127.0.0.1:8000 for a local development server,
-- or http://192.168.1.1 for the web interface of many routers.
{
regex = [[\b\w+://(?:[\d]{1,3}\.){3}[\d]{1,3}\S*\b]],
format = '$0',
},
-- Make task numbers clickable
-- The first matched regex group is captured in $1.
{
regex = [[\b[tT](\d+)\b]],
format = 'https://example.com/tasks/?t=$1',
},
-- Make username/project paths clickable. This implies paths like the following are for GitHub.
-- ( "nvim-treesitter/nvim-treesitter" | wbthomason/packer.nvim | wez/wezterm | "wez/wezterm.git" )
-- As long as a full URL hyperlink regex exists above this it should not match a full URL to
-- GitHub or GitLab / BitBucket (i.e. https://gitlab.com/user/project.git is still a whole clickable URL)
{
regex = [[["]?([\w\d]{1}[-\w\d]+)(/){1}([-\w\d\.]+)["]?]],
format = 'https://www.github.com/$1/$3',
},
},
}