Skip to content

Commit f4a27dd

Browse files
Refactor WezTerm configuration to use config_builder for improved readability and organization. Update font settings, color scheme, window properties, and key bindings while maintaining existing functionality.
1 parent 0d7b639 commit f4a27dd

1 file changed

Lines changed: 145 additions & 121 deletions

File tree

common/wezterm/.wezterm.lua

Lines changed: 145 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -12,148 +12,170 @@ local wezterm = require("wezterm")
1212

1313
local act = wezterm.action
1414

15-
local config = {
16-
check_for_updates = true,
17-
font_size = 12,
18-
font = wezterm.font_with_fallback({
19-
{ family = "CaskaydiaMono Nerd Font", weight = "Regular" },
20-
}),
21-
line_height = 1.0,
22-
23-
color_scheme = "Catppuccin Mocha",
24-
set_environment_variables = {
25-
BAT_THEME = "Catppuccin-mocha",
26-
},
27-
28-
inactive_pane_hsb = { saturation = 0.95, brightness = 0.95 },
15+
local config = wezterm.config_builder()
2916

30-
initial_cols = 120,
31-
initial_rows = 30,
17+
-- ── Updates ──────────────────────────────────────────────────────────────────
3218

33-
adjust_window_size_when_changing_font_size = false,
34-
window_close_confirmation = "NeverPrompt",
35-
window_background_opacity = 0.6,
36-
text_background_opacity = 0.95,
37-
win32_system_backdrop = "Acrylic",
19+
config.check_for_updates = true
3820

39-
window_decorations = "INTEGRATED_BUTTONS|RESIZE",
21+
-- ── Font ─────────────────────────────────────────────────────────────────────
4022

41-
enable_tab_bar = true,
42-
use_fancy_tab_bar = true,
43-
hide_tab_bar_if_only_one_tab = false,
44-
show_new_tab_button_in_tab_bar = true,
23+
config.font_size = 12
24+
config.font = wezterm.font_with_fallback({
25+
{ family = "CaskaydiaMono Nerd Font", weight = "Regular" },
26+
})
27+
config.line_height = 1.0
4528

46-
default_cursor_style = "BlinkingBar",
47-
cursor_blink_rate = 500,
48-
animation_fps = 60,
29+
-- ── Appearance ────────────────────────────────────────────────────────────────
4930

50-
wsl_domains = wezterm.default_wsl_domains(),
51-
default_domain = "WSL:Ubuntu",
31+
config.color_scheme = "Catppuccin Mocha"
32+
config.set_environment_variables = {
33+
BAT_THEME = "Catppuccin-mocha",
34+
}
5235

53-
window_padding = { left = 0, right = 0, top = 0, bottom = 0 },
54-
enable_scroll_bar = true,
36+
config.inactive_pane_hsb = { saturation = 0.95, brightness = 0.95 }
5537

56-
status_update_interval = 1000,
38+
config.window_background_opacity = 0.6
39+
config.text_background_opacity = 0.95
40+
config.win32_system_backdrop = "Acrylic"
5741

58-
window_frame = {
59-
font = wezterm.font({ family = "Segoe UI", weight = "Bold" }),
60-
font_size = 12,
61-
active_titlebar_bg = "#f3f3f3",
62-
inactive_titlebar_bg = "#ececec",
63-
},
42+
config.window_decorations = "INTEGRATED_BUTTONS|RESIZE"
43+
config.window_padding = { left = 0, right = 0, top = 0, bottom = 0 }
6444

65-
integrated_title_button_color = "Auto",
66-
67-
colors = {
68-
tab_bar = {
69-
inactive_tab_edge = "#d3d3d3",
70-
71-
active_tab = {
72-
bg_color = "#ffffff",
73-
fg_color = "#1f1f1f",
74-
intensity = "Bold",
75-
},
76-
inactive_tab = {
77-
bg_color = "#eaeaea",
78-
fg_color = "#4b4b4b",
79-
intensity = "Normal",
80-
},
81-
inactive_tab_hover = {
82-
bg_color = "#e0e0e0",
83-
fg_color = "#202020",
84-
italic = true,
85-
},
86-
new_tab = {
87-
bg_color = "#efefef",
88-
fg_color = "#6a6a6a",
89-
},
90-
new_tab_hover = {
91-
bg_color = "#e0e0e0",
92-
fg_color = "#202020",
93-
italic = true,
94-
},
95-
},
96-
selection_fg = "none",
97-
selection_bg = "rgba(203,166,247,0.35)",
98-
},
45+
config.window_frame = {
46+
font = wezterm.font({ family = "Segoe UI", weight = "Bold" }),
47+
font_size = 12,
48+
active_titlebar_bg = "#f3f3f3",
49+
inactive_titlebar_bg = "#ececec",
50+
}
9951

100-
launch_menu = {
101-
{
102-
label = "PowerShell",
103-
domain = { DomainName = "local" },
104-
args = { "pwsh", "-NoLogo" },
105-
},
106-
{
107-
label = "Ubuntu",
108-
domain = { DomainName = "WSL:Ubuntu" },
109-
},
110-
{
111-
label = "Debian",
112-
domain = { DomainName = "WSL:Debian" },
113-
},
114-
},
52+
config.integrated_title_button_color = "Auto"
11553

116-
treat_left_ctrlalt_as_altgr = false,
54+
config.colors = {
55+
tab_bar = {
56+
inactive_tab_edge = "#d3d3d3",
11757

118-
keys = {
119-
{
120-
key = "p",
121-
mods = "CTRL|ALT",
122-
action = act.SpawnCommandInNewTab({
123-
domain = { DomainName = "local" },
124-
args = { "pwsh", "-NoLogo" },
125-
}),
58+
active_tab = {
59+
bg_color = "#ffffff",
60+
fg_color = "#1f1f1f",
61+
intensity = "Bold",
12662
},
127-
{
128-
key = "u",
129-
mods = "CTRL|ALT",
130-
action = act.SpawnTab({ DomainName = "WSL:Ubuntu" }),
63+
inactive_tab = {
64+
bg_color = "#eaeaea",
65+
fg_color = "#4b4b4b",
66+
intensity = "Normal",
13167
},
132-
{
133-
key = "d",
134-
mods = "CTRL|ALT",
135-
action = act.SpawnTab({ DomainName = "WSL:Debian" }),
68+
inactive_tab_hover = {
69+
bg_color = "#e0e0e0",
70+
fg_color = "#202020",
71+
italic = true,
13672
},
137-
{
138-
key = "w",
139-
mods = "ALT",
140-
action = act.CloseCurrentTab({ confirm = false }),
73+
new_tab = {
74+
bg_color = "#efefef",
75+
fg_color = "#6a6a6a",
14176
},
142-
{
143-
key = "l",
144-
mods = "ALT",
145-
action = act.ShowLauncherArgs({ flags = "LAUNCH_MENU_ITEMS" }),
77+
new_tab_hover = {
78+
bg_color = "#e0e0e0",
79+
fg_color = "#202020",
80+
italic = true,
14681
},
14782
},
148-
mouse_bindings = {
149-
{
150-
event = { Down = { streak = 1, button = "Right" } },
151-
mods = "NONE",
152-
action = act({ PasteFrom = "Clipboard" }),
153-
},
83+
selection_fg = "none",
84+
selection_bg = "rgba(137,180,250,0.35)",
85+
}
86+
87+
-- ── Window ────────────────────────────────────────────────────────────────────
88+
89+
config.initial_cols = 120
90+
config.initial_rows = 30
91+
92+
config.adjust_window_size_when_changing_font_size = false
93+
config.window_close_confirmation = "NeverPrompt"
94+
config.enable_scroll_bar = true
95+
96+
-- ── Tab bar ───────────────────────────────────────────────────────────────────
97+
98+
config.enable_tab_bar = true
99+
config.use_fancy_tab_bar = true
100+
config.hide_tab_bar_if_only_one_tab = false
101+
config.show_new_tab_button_in_tab_bar = true
102+
103+
-- ── Cursor ────────────────────────────────────────────────────────────────────
104+
105+
config.default_cursor_style = "BlinkingBar"
106+
config.cursor_blink_rate = 500
107+
config.animation_fps = 60
108+
109+
-- ── Status bar ────────────────────────────────────────────────────────────────
110+
111+
config.status_update_interval = 1000
112+
113+
-- ── Domains ───────────────────────────────────────────────────────────────────
114+
115+
config.wsl_domains = wezterm.default_wsl_domains()
116+
config.default_domain = "WSL:Ubuntu"
117+
118+
config.launch_menu = {
119+
{
120+
label = "PowerShell",
121+
domain = { DomainName = "local" },
122+
args = { "pwsh", "-NoLogo" },
123+
},
124+
{
125+
label = "Ubuntu",
126+
domain = { DomainName = "WSL:Ubuntu" },
127+
},
128+
{
129+
label = "Debian",
130+
domain = { DomainName = "WSL:Debian" },
154131
},
155132
}
156133

134+
-- ── Key bindings ──────────────────────────────────────────────────────────────
135+
136+
config.treat_left_ctrlalt_as_altgr = false
137+
138+
config.keys = {
139+
{
140+
key = "p",
141+
mods = "CTRL|ALT",
142+
action = act.SpawnCommandInNewTab({
143+
domain = { DomainName = "local" },
144+
args = { "pwsh", "-NoLogo" },
145+
}),
146+
},
147+
{
148+
key = "u",
149+
mods = "CTRL|ALT",
150+
action = act.SpawnTab({ DomainName = "WSL:Ubuntu" }),
151+
},
152+
{
153+
key = "d",
154+
mods = "CTRL|ALT",
155+
action = act.SpawnTab({ DomainName = "WSL:Debian" }),
156+
},
157+
{
158+
key = "w",
159+
mods = "ALT",
160+
action = act.CloseCurrentTab({ confirm = false }),
161+
},
162+
{
163+
key = "l",
164+
mods = "ALT",
165+
action = act.ShowLauncherArgs({ flags = "LAUNCH_MENU_ITEMS" }),
166+
},
167+
}
168+
169+
config.mouse_bindings = {
170+
{
171+
event = { Down = { streak = 1, button = "Right" } },
172+
mods = "NONE",
173+
action = act({ PasteFrom = "Clipboard" }),
174+
},
175+
}
176+
177+
-- ── Events ────────────────────────────────────────────────────────────────────
178+
157179
local function titlebar_bg_for_focus(window)
158180
local ef = window:effective_config()
159181
local wf = ef.window_frame or {}
@@ -173,10 +195,12 @@ wezterm.on("update-status", function(window, pane)
173195
window:set_right_status(wezterm.format({
174196
"ResetAttributes",
175197
{ Background = { Color = titlebar_bg_for_focus(window) } },
176-
{ Foreground = { Color = "#f5c2e7" } },
198+
{ Foreground = { Color = "#cba6f7" } },
177199
{ Attribute = { Intensity = "Bold" } },
178200
{ Text = " " .. table.concat(cells, " ") .. " " },
179201
}))
180202
end)
181203

204+
-- ── Return ────────────────────────────────────────────────────────────────────
205+
182206
return config

0 commit comments

Comments
 (0)