-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwezterm.lua
More file actions
199 lines (181 loc) · 6.55 KB
/
wezterm.lua
File metadata and controls
199 lines (181 loc) · 6.55 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
local wezterm = require("wezterm")
local act = wezterm.action
local config = {}
-- Use config builder object if possible
if wezterm.config_builder then
config = wezterm.config_builder()
end
config.color_scheme = "Tokyo Night"
config.font_size = 13
config.window_background_opacity = 1
config.window_close_confirmation = "AlwaysPrompt"
config.default_domain = "WSL:openSUSE-Tumbleweed"
config.scrollback_lines = 3000
config.window_decorations = "INTEGRATED_BUTTONS|RESIZE"
config.default_workspace = "main"
wezterm.on("gui-startup", function()
local tab, pane, window = wezterm.mux.spawn_window({})
window:gui_window():maximize()
end)
-- Dim inactive panes
config.inactive_pane_hsb = {
saturation = 0.8,
brightness = 0.8,
}
-- Keys
config.leader = { key = "q", mods = "CTRL", timeout_milliseconds = 1000 }
config.keys = {
{ key = "q", mods = "LEADER|CTRL", action = act.SendKey({ key = "q", mods = "CTRL" }) },
{ key = "c", mods = "LEADER", action = act.ActivateCopyMode },
{ key = "phys:Space", mods = "LEADER", action = act.ActivateCommandPalette },
-- Pane keybindings
{ key = "v", mods = "LEADER", action = act.SplitVertical({ domain = "CurrentPaneDomain" }) },
{ key = "s", mods = "LEADER", action = act.SplitHorizontal({ 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 = false }) },
{ key = "f", mods = "LEADER", action = act.TogglePaneZoomState },
{ key = "o", mods = "LEADER", action = act.RotatePanes("Clockwise") },
-- Zellij like keybindings
{ key = "n", mods = "ALT", action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }) },
{ key = "h", mods = "ALT", action = act.ActivatePaneDirection("Left") },
{ key = "j", mods = "ALT", action = act.ActivatePaneDirection("Down") },
{ key = "k", mods = "ALT", action = act.ActivatePaneDirection("Up") },
{ key = "l", mods = "ALT", action = act.ActivatePaneDirection("Right") },
-- We can make separate keybindings for resizing panes
-- But Wezterm offers custom "mode" in the name of "KeyTable"
{
key = "r",
mods = "LEADER",
action = act.ActivateKeyTable({ name = "resize_pane", one_shot = false }),
},
-- Tab 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 },
{
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),
}),
},
-- Key table for moving tabs around
{ key = "m", mods = "LEADER", action = act.ActivateKeyTable({ name = "move_tab", one_shot = false }) },
-- Or shortcuts to move tab w/o move_tab table. SHIFT is for when caps lock is on
{ key = "{", mods = "LEADER|SHIFT", action = act.MoveTabRelative(-1) },
{ key = "}", mods = "LEADER|SHIFT", action = act.MoveTabRelative(1) },
-- Lastly, workspace
{ key = "w", mods = "LEADER", action = act.ShowLauncherArgs({ flags = "FUZZY|WORKSPACES" }) },
}
-- I can use the tab navigator (LDR t), but I also want to quickly navigate tabs with index
for i = 1, 9 do
table.insert(config.keys, {
key = tostring(i),
mods = "LEADER",
action = act.ActivateTab(i - 1),
})
end
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" },
},
}
-- Tab bar
-- I don't like the look of "fancy" tab bar
config.use_fancy_tab_bar = false
config.status_update_interval = 1000
config.tab_bar_at_bottom = false
wezterm.on("update-status", function(window, pane)
-- Workspace name
local stat = window:active_workspace()
local stat_color = "#f7768e"
-- It's a little silly to have workspace name all the time
-- Utilize this to display LDR or current key table name
if window:active_key_table() then
stat = window:active_key_table()
stat_color = "#7dcfff"
end
if window:leader_is_active() then
stat = "LDR"
stat_color = "#bb9af7"
end
local basename = function(s)
-- Nothing a little regex can't fix
return string.gsub(s, "(.*[/\\])(.*)", "%2")
end
-- Current working directory
local cwd = pane:get_current_working_dir()
if cwd then
if type(cwd) == "userdata" then
-- Wezterm introduced the URL object in 20240127-113634-bbcac864
cwd = basename(cwd.file_path)
else
-- 20230712-072601-f4abf8fd or earlier version
cwd = basename(cwd)
end
else
cwd = ""
end
-- Current command
local cmd = pane:get_foreground_process_name()
-- CWD and CMD could be nil (e.g. viewing log using Ctrl-Alt-l)
cmd = cmd and basename(cmd) or ""
-- Time
local time = wezterm.strftime("%H:%M")
-- Left status (left of the tab line)
window:set_left_status(wezterm.format({
{ Foreground = { Color = stat_color } },
{ Text = " " },
{ Text = wezterm.nerdfonts.oct_table .. " " .. stat },
{ Text = " |" },
}))
end)
-- config.window_frame = {
-- font = wezterm.font({ family = "JetBrains Mono", weight = "Bold" }),
--
-- -- The size of the font in the tab bar.
-- -- Default to 10.0 on Windows but 12.0 on other systems
-- font_size = 11.0,
--
-- -- The overall background color of the tab bar when
-- -- the window is focused
-- active_titlebar_bg = "#1a1b26",
--
-- -- The overall background color of the tab bar when
-- -- the window is not focused
-- inactive_titlebar_bg = "#1a1b26",
-- }
--
-- config.colors = {
-- tab_bar = {
-- -- The color of the inactive tab bar edge/divider
-- inactive_tab_edge = "#1a1b26",
-- },
-- }
return config