-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwezterm.lua
More file actions
348 lines (307 loc) · 11.5 KB
/
wezterm.lua
File metadata and controls
348 lines (307 loc) · 11.5 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
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
local wezterm = require("wezterm")
local gui = wezterm.gui
local act = wezterm.action
local font = wezterm.font
local config = {}
local mouse_bindings = {}
local launch_menu = {}
local icon_mappings = {
processes = {
nvim = wezterm.nerdfonts.custom_neovim,
zsh = wezterm.nerdfonts.cod_terminal,
bash = wezterm.nerdfonts.cod_terminal_bash,
git = wezterm.nerdfonts.fa_git,
},
extensions = {
[".lua"] = wezterm.nerdfonts.md_language_lua,
[".svelte"] = wezterm.nerdfonts.seti_svelte,
[".js"] = wezterm.nerdfonts.dev_javascript,
[".rb"] = wezterm.nerdfonts.dev_ruby,
[".go"] = wezterm.nerdfonts.custom_go,
[".py"] = wezterm.nerdfonts.dev_python,
[".ts"] = wezterm.nerdfonts.dev_typescript,
[".html"] = wezterm.nerdfonts.dev_html5,
[".css"] = wezterm.nerdfonts.dev_css3,
},
directories = {
Documents = wezterm.nerdfonts.fa_folder_open,
Projects = wezterm.nerdfonts.dev_code,
Downloads = wezterm.nerdfonts.fa_download,
Music = wezterm.nerdfonts.fa_music,
Pictures = wezterm.nerdfonts.fa_image,
Videos = wezterm.nerdfonts.fa_video,
OneDrive = wezterm.nerdfonts.dev_onedrive,
},
default_icon = wezterm.nerdfonts.cod_file,
}
-- Function to dynamically set icons in tab titles
wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_width)
local title = tab.active_pane.title
local process_name = tab.active_pane.foreground_process_name
-- Check if there's an icon for the process
for proc, icon in pairs(icon_mappings.processes) do
if process_name and process_name:find(proc) then
title = icon .. " " .. title
return title
end
end
end)
-- Uncomment this block if you want to display a status bar with date, time, and battery info.
-- The status bar is set to display on the right side of the terminal window.
-- wezterm.on("update-right-status", function(window, pane)
-- local date = wezterm.strftime("%a %-d %b %y %H:%M ")
-- local bat = ""
--
-- for _, b in ipairs(wezterm.battery_info()) do
-- bat = wezterm.nerdfonts.md_battery .. " " .. string.format("%.0f%%", b.state_of_charge * 100)
-- end
--
-- -- Set the right status to the date and battery status of the current pane in the window
-- window:set_right_status(wezterm.format({
-- { Text = " | " .. wezterm.nerdfonts.fa_clock_o .. " " .. date .. " | " .. bat .. " | " },
-- }))
--
-- -- Optionally, you can also set a left status with the terminal title or other info.
-- window:set_left_status(wezterm.format({
-- { Text = " | " .. wezterm.nerdfonts.fa_terminal .. " " .. pane.title .. " | " },
-- }))
-- end)
-- Use the `wezterm` module to build the configuration if supported
if wezterm.config_builder then
config = wezterm.config_builder()
end
-- Define the launch menu items
config.launch_menu = launch_menu
-- Disable the tab bar as it’s not needed; setting it at the bottom if enabled
config.enable_tab_bar = false
config.tab_bar_at_bottom = false
config.enable_tab_bar = true
config.tab_bar_at_bottom = false
wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_width)
-- Get the current working directory of the active pane
local cwd_uri = tab.active_pane.current_working_dir
local cwd = ""
-- Convert the URI to a more readable path, if available
if cwd_uri then
local home = os.getenv("HOME")
cwd = cwd_uri:match("file://[^/]*(/.*)")
if home and cwd == home then
cwd = "~"
elseif home and cwd:find(home, 1, true) == 1 then
cwd = "~" .. cwd:sub(#home + 1)
end
end
local title = " " .. cwd .. " "
if tab.is_active then
return {
{ Background = { Color = "#7aa2f7" } },
{ Foreground = { Color = "#24283b" } },
{ Foreground = { Color = "#1a1b26" } },
{ Text = title },
{ Foreground = { Color = "#24283b" } },
}
else
return {
{ Background = { Color = "#1a1b26" } },
{ Foreground = { Color = "#24283b" } },
{ Foreground = { Color = "#a9b1d6" } },
{ Text = title },
{ Foreground = { Color = "#24283b" } },
}
end
end)
-- Tokyo Night Storm colors with custom styling for tabs
config.colors = {
tab_bar = {
background = "#24283b",
-- Active tab styling
active_tab = {
bg_color = "#7aa2f7",
fg_color = "#1a1b26",
intensity = "Bold",
},
-- Inactive tab styling
inactive_tab = {
bg_color = "#1a1b26",
fg_color = "#a9b1d6",
},
-- Hover effect for inactive tabs
inactive_tab_hover = {
bg_color = "#3b4261",
fg_color = "#c0caf5",
italic = true,
},
-- New tab styling
new_tab = {
bg_color = "#24283b",
fg_color = "#7aa2f7",
},
-- New tab hover styling
new_tab_hover = {
bg_color = "#7aa2f7",
fg_color = "#1a1b26",
underline = "Single",
},
},
}
config.window_padding = {
left = 1,
right = 1,
top = 0,
bottom = 0,
}
-- Function to get the current system appearance (e.g., Dark or Light mode)
local function get_appearance()
if gui then
return gui.get_appearance()
end
return "Dark" -- Default to Dark if GUI isn't available
end
-- Select a color scheme based on the system appearance
local function scheme_for_appearance(appearance)
if appearance:find("Dark") then
return "tokyonight_storm"
else
return "tokyonight_night"
end
end
-- Customize various settings for a better appearance and readability
config.line_height = 1.2
config.font = wezterm.font_with_fallback({
{ family = "CaskaydiaCove Nerd Font", scale = 1.2, weight = "Medium" }, -- Main font with medium weight
{ family = "FiraCode Nerd Font", scale = 1.2 },
})
config.color_scheme = scheme_for_appearance(get_appearance())
-- Uncomment and set the following options if you want a custom background image
-- config.window_background_image = "/path/to/wallpaper.png"
-- config.window_background_image_hsb = {
-- hue = 1.0,
-- saturation = 1.0,
-- brightness = 0.3,
-- }
-- Set the cursor style and window opacity
config.default_cursor_style = "BlinkingBar"
config.window_background_opacity = 0.9
-- Set window decorations and behavior
config.window_decorations = "RESIZE"
config.window_close_confirmation = "AlwaysPrompt"
config.scrollback_lines = 3500
config.default_workspace = "main"
config.enable_scroll_bar = true
-- Customize the appearance of the window frame
config.window_frame = {
font = font({ family = "CaskaydiaCove Nerd Font", weight = "Bold" }),
font_size = 14.0,
-- active_titlebar_bg = "#2E3440", -- Uncomment to set active title bar background color
-- inactive_titlebar_bg = "#2E3440", -- Uncomment to set inactive title bar background color
}
-- Brighten the foreground text for better contrast against the background
config.foreground_text_hsb = {
hue = 1.0,
saturation = 1.2,
brightness = 1.5,
}
-- Adjust the appearance of inactive panes to differentiate them from active panes
config.inactive_pane_hsb = {
hue = 0.0,
saturation = 0.25,
brightness = 0.5,
}
-- Keybindings settings: Disable default bindings and define custom ones
config.disable_default_key_bindings = true
config.leader = { key = "a", mods = "CTRL", timeout_milliseconds = 1000 }
config.keys = {
-- Leader key configuration for quick access to commonly used actions
{ key = "a", mods = "LEADER", action = act.SendKey({ key = "a", mods = "CTRL" }) },
{ key = "c", mods = "LEADER", action = act.ActivateCopyMode },
-- Pane management keybindings
{ key = "|", mods = "LEADER", action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }) },
{ key = "-", mods = "LEADER", action = act.SplitVertical({ domain = "CurrentPaneDomain" }) },
{ key = "h", mods = "LEADER", action = act.ActivatePaneDirection("Left") },
{ key = "j", mods = "LEADER", action = act.ActivatePaneDirection("Down") },
{ key = "k", mods = "LEADER", action = act.ActivatePaneDirection("Up") },
{ key = "l", mods = "LEADER", action = act.ActivatePaneDirection("Right") },
{ key = "q", mods = "LEADER", action = act.CloseCurrentPane({ confirm = true }) },
{ key = "z", mods = "LEADER", action = act.TogglePaneZoomState },
{ key = "o", mods = "LEADER", action = act.RotatePanes("Clockwise") },
-- Resizing panes using a dedicated key table
{ key = "r", mods = "LEADER", action = act.ActivateKeyTable({ name = "resize_pane", one_shot = false }) },
-- Moving tabs within the terminal window
{ key = "m", mods = "LEADER", action = act.ActivateKeyTable({ name = "move_tab", one_shot = false }) },
{ key = "{", mods = "LEADER|ALT", action = act.MoveTabRelative(-1) },
{ key = "}", mods = "LEADER|ALT", action = act.MoveTabRelative(1) },
-- Tab management keybindings
{ key = "t", mods = "LEADER", action = act.SpawnTab("CurrentPaneDomain") },
{ key = "[", mods = "LEADER", action = act.ActivateTabRelative(-1) },
{ key = "]", mods = "LEADER", action = act.ActivateTabRelative(1) },
{ key = "n", mods = "LEADER", action = act.ShowTabNavigator },
-- Rename the current tab
{
key = "e",
mods = "LEADER",
action = act.PromptInputLine({
description = wezterm.format({
{ Attribute = { Intensity = "Bold" } },
{ Foreground = { AnsiColor = "Fuchsia" } },
{ Text = "Renaming Tab Title...:" },
}),
action = wezterm.action_callback(function(window, pane, line)
if line then
window:active_tab():set_title(line)
end
end),
}),
},
-- Clipboard actions for copy and paste
{ key = "v", mods = "CTRL", action = act.PasteFrom("Clipboard") },
{ key = "c", mods = "CTRL", action = act.CopyTo("ClipboardAndPrimarySelection") },
-- Workspace management
{ key = "w", mods = "LEADER", action = act.ShowLauncherArgs({ flags = "FUZZY|WORKSPACES" }) },
}
-- Additional keybindings for direct tab activation (e.g., LDR 1 for the first tab)
for i = 1, 9 do
table.insert(config.keys, { key = tostring(i), mods = "LEADER", action = act.ActivateTab(i - 1) })
end
-- Define key tables for resize and move tab actions
config.key_tables = {
resize_pane = {
{ key = "h", action = act.AdjustPaneSize({ "Left", 1 }) },
{ key = "j", action = act.AdjustPaneSize({ "Down", 1 }) },
{ key = "k", action = act.AdjustPaneSize({ "Up", 1 }) },
{ key = "l", action = act.AdjustPaneSize({ "Right", 1 }) },
{ key = "Escape", action = "PopKeyTable" },
{ key = "Enter", action = "PopKeyTable" },
},
move_tab = {
{ key = "h", action = act.MoveTabRelative(-1) },
{ key = "j", action = act.MoveTabRelative(-1) },
{ key = "k", action = act.MoveTabRelative(1) },
{ key = "l", action = act.MoveTabRelative(1) },
{ key = "Escape", action = "PopKeyTable" },
{ key = "Enter", action = "PopKeyTable" },
},
}
-- Mouse bindings: Customize mouse actions, like triple-click to select text
config.mouse_bindings = mouse_bindings
mouse_bindings = {
{
event = { Down = { streak = 3, button = "Left" } },
action = act.SelectTextAtMouseCursor("SemanticZone"),
mods = "NONE",
},
{
event = { Down = { streak = 1, button = "Right" } },
mods = "NONE",
action = wezterm.action_callback(function(window, pane)
local has_selection = window:get_selection_text_for_pane(pane) ~= ""
if has_selection then
window:perform_action(act.CopyTo("ClipboardAndPrimarySelection"), pane)
window:perform_action(act.ClearSelection, pane)
else
window:perform_action(act({ PasteForm = "Clipboard" }), pane)
end
end),
},
}
-- Return the final configuration table
return config