-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.wezterm.lua
More file actions
282 lines (258 loc) · 8.41 KB
/
.wezterm.lua
File metadata and controls
282 lines (258 loc) · 8.41 KB
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
-- Pull in the wezterm API
local wezterm = require 'wezterm'
local act = wezterm.action
-- This table will hold the configuration.
local config = {}
-- In newer versions of wezterm, use the config_builder which will
-- help provide clearer error messages
if wezterm.config_builder then
config = wezterm.config_builder()
end
-- This is where you actually apply your config choices
-- Colors
local my_dimmed_monokai = wezterm.get_builtin_color_schemes()['DimmedMonokai']
my_dimmed_monokai.foreground = '999'
my_dimmed_monokai.background = '#1B1B1B' -- 1E1E1E originally
my_dimmed_monokai.cursor_bg = 'grey'
my_dimmed_monokai.cursor_border = my_dimmed_monokai.cursor_bg
config.color_schemes = {
['DimmedMonokai'] = my_dimmed_monokai
}
-- browns
-- config.color_scheme = 'Marrakesh (base16)'
-- blues
-- config.color_scheme = 'Mirage'
-- config.color_scheme = 'PhD (base16)'
-- config.color_scheme = 'Solarized (dark) (terminal.sexy)'
-- config.color_scheme = 'Atlas (base16)'
-- mains
config.color_scheme = 'DimmedMonokai'
-- config.color_scheme = 'Pretty and Pastel (terminal.sexy)'
-- config.color_scheme = 'Tangoesque (terminal.sexy)' -- red symlinks -> pink
-- config.color_scheme = 'Equilibrdium Gray Dark (base16)'
-- config.color_scheme = 'Terminix Dark (Gogh)' -- purple synlinks -> pink
config.font = wezterm.font_with_fallback({ 'Menlo', 'Roboto Mono', 'JetBrains Mono', 'Monaco', 'monospace' })
-- Tab bar
config.window_frame = {
-- The font used in the tab bar.
-- Roboto Bold is the default; this font is bundled
-- with wezterm.
-- Whatever font is selected here, it will have the
-- main font setting appended to it to pick up any
-- fallback fonts you may have used there.
font = wezterm.font { family = 'JetBrains' },
-- The size of the font in the tab bar.
-- Default to 10.0 on Windows but 12.0 on other systems
font_size = 12.0,
}
config.colors = {
tab_bar = {
-- The active tab is the one that has focus in the window
active_tab = {
-- The color of the background area for the tab
fg_color = '#CCCCCC',
bg_color = config.color_schemes['DimmedMonokai'].background,
},
}
}
config.native_macos_fullscreen_mode = true
config.tab_bar_at_bottom = true
-- disable ligatures
config.harfbuzz_features = { "calt=0", "clig=0", "liga=0" }
-- config.cursor_blink_rate = 800
-- Cache for git branches per pane (pane_id -> {cwd=..., branch=...})
local git_branch_cache = {}
-- Helper to extract path from file:// URI object
local function uri_to_path(cwd_uri)
if not cwd_uri then
return nil
end
-- Handle URL object (has file_path property)
if type(cwd_uri) == 'userdata' then
return cwd_uri.file_path
end
if type(cwd_uri) == 'table' and cwd_uri.file_path then
return cwd_uri.file_path
end
-- String format: file://hostname/path
if type(cwd_uri) == 'string' then
return cwd_uri:gsub('file://[^/]*', '')
end
return nil
end
-- Update git branch cache for a pane (called from update-status)
local function update_git_branch_cache(pane)
local cwd_uri = pane:get_current_working_dir()
local cwd = uri_to_path(cwd_uri)
local pane_id = pane:pane_id()
if cwd then
local success, stdout, stderr = wezterm.run_child_process({
'git', '-C', cwd, 'rev-parse', '--abbrev-ref', 'HEAD'
})
local branch = nil
if success and stdout then
branch = stdout:gsub('%s+', '')
if #branch == 0 then
branch = nil
end
end
git_branch_cache[pane_id] = { cwd = cwd, branch = branch }
end
end
-- Tab title: show git branch if available, otherwise process name
-- Respects manually set tab titles (via LEADER + ,)
wezterm.on('format-tab-title', function(tab, tabs, panes, cfg, hover, max_width)
local tab_number = tab.tab_index + 1 -- 1-indexed for display
local title
-- Check if tab has a manually set title
local tab_title = tab.tab_title
if tab_title and #tab_title > 0 then
title = tab_title
else
-- Check cache for git branch
local pane_id = tab.active_pane.pane_id
local cached = git_branch_cache[pane_id]
if cached and cached.branch then
title = cached.branch
else
-- Fall back to default: process name (basename only)
local process = tab.active_pane.foreground_process_name or tab.active_pane.title or ''
title = process:gsub('.*/', '')
end
end
return tab_number .. ': ' .. title
end)
-- right status bar display date/time
wezterm.on("update-status", function(window, pane)
-- Update git branch cache for tab title
update_git_branch_cache(pane)
-- However, if all you need is to format the date/time, then:
local date = wezterm.strftime(" %A %b %d ");
local date_time = wezterm.strftime(" %H:%M:%S ");
-- Make it italic and underlined
window:set_right_status(wezterm.format({
{ Background = { Color = "666" } },
{ Foreground = { Color = "111" } },
{ Text = date },
{ Background = { Color = "888" } },
{ Foreground = { Color = "111" } },
{ Text = date_time },
}));
end);
-- keybinds
-- timeout_milliseconds defaults to 1000 and can be omitted
config.leader = { key = 'a', mods = 'CTRL', timeout_milliseconds = 1000 }
config.keys = {
-- Tabs
{
key = 'c',
mods = 'LEADER',
action = wezterm.action.SpawnTab 'CurrentPaneDomain',
},
{
key = ',',
mods = 'LEADER',
action = wezterm.action.PromptInputLine {
description = 'Enter new name for tab',
action = wezterm.action_callback(function(window, pane, line)
-- line will be `nil` if they hit escape without entering anything
-- An empty string if they just hit enter
-- Or the actual line of text they wrote
if line then
window:active_tab():set_title(line)
end
end),
},
},
{
-- Panes
key = '|',
mods = 'LEADER|SHIFT',
action = wezterm.action.SplitHorizontal { domain = 'CurrentPaneDomain' },
},
{
key = '-',
mods = 'LEADER',
action = wezterm.action.SplitVertical { domain = 'CurrentPaneDomain' },
},
{
key = 'x',
mods = 'LEADER',
action = wezterm.action.CloseCurrentPane { domain = 'DefaultDomain', confirm = false },
},
{
key = 'n',
mods = 'LEADER',
action = wezterm.action.ActivateTabRelative(1),
},
{
key = 'p',
mods = 'LEADER',
action = wezterm.action.ActivateTabRelative(-1),
},
{
key = 'LeftArrow',
mods = 'LEADER',
action = wezterm.action.ActivatePaneDirection 'Left',
},
{
key = 'RightArrow',
mods = 'LEADER',
action = wezterm.action.ActivatePaneDirection 'Right',
},
{
key = 'UpArrow',
mods = 'LEADER',
action = wezterm.action.ActivatePaneDirection 'Up',
},
{
key = 'DownArrow',
mods = 'LEADER',
action = wezterm.action.ActivatePaneDirection 'Down',
},
{
key = 'h',
mods = 'LEADER',
action = wezterm.action.ActivatePaneDirection 'Left',
},
{
key = 'l',
mods = 'LEADER',
action = wezterm.action.ActivatePaneDirection 'Right',
},
{
key = 'k',
mods = 'LEADER',
action = wezterm.action.ActivatePaneDirection 'Up',
},
{
key = 'j',
mods = 'LEADER',
action = wezterm.action.ActivatePaneDirection 'Down',
},
{
key = 'z',
mods = 'LEADER',
action = wezterm.action.TogglePaneZoomState,
},
-- Send "CTRL-A" to the terminal when pressing CTRL-A, CTRL-A
{
key = 'a',
mods = 'LEADER|CTRL',
action = wezterm.action.SendKey { key = 'a', mods = 'CTRL' },
},
-- Make Command-Backspace equivalent to Ctrl-u; kill-line
{ key = 'Backspace', mods = 'CMD', action = act { SendString = '\x15' } },
}
-- Tabs nav by id
for i = 1, 9 do
-- LEADER + number to activate that tab
table.insert(config.keys, {
key = tostring(i),
mods = 'LEADER',
action = wezterm.action.ActivateTab(i - 1),
})
end
config.scrollback_lines = 500000
-- and finally, return the configuration to wezterm
return config