Last active 1729607880

My wezterm configuration

Revision 6f9ec333a8d7561f2d49ecd21649f05b02ea3e86

wezterm.lua Raw
1-- Pull in the wezterm API, some of its modules, and plugins
2local wezterm = require 'wezterm'
3local act = wezterm.action
4local merge = require 'merge'
5local mux = wezterm.mux
6local resurrect = require 'resurrect/config'
7local smart_splits = require 'smart-splits/setup'
8
9-- --------------------------------------------------------------------
10-- CONFIGURATION
11-- --------------------------------------------------------------------
12
13-- This table will hold the configuration.
14local config = {}
15
16-- In newer versions of wezterm, use the config_builder which will
17-- help provide clearer error messages
18if wezterm.config_builder then
19 config = wezterm.config_builder()
20end
21
22config.adjust_window_size_when_changing_font_size = false
23config.automatically_reload_config = true
24config.color_scheme = 'Solarized (dark) (terminal.sexy)'
25config.enable_scroll_bar = true
26config.enable_wayland = true
27-- config.font = wezterm.font('Hack')
28config.font = wezterm.font('MonaspiceNe NFP')
29config.font_size = 12.0
30config.hide_tab_bar_if_only_one_tab = false
31-- The leader is similar to how tmux defines a set of keys to hit in order to
32-- invoke tmux bindings. Binding to ctrl-a here to mimic tmux
33config.leader = { key = 'a', mods = 'CTRL', timeout_milliseconds = 2000 }
34config.mouse_bindings = {
35 -- Open URLs with Ctrl+Click
36 {
37 event = { Up = { streak = 1, button = 'Left' } },
38 mods = 'CTRL',
39 action = act.OpenLinkAtMouseCursor,
40 }
41}
42config.pane_focus_follows_mouse = true
43config.scrollback_lines = 5000
44config.tiling_desktop_environments = {
45 'Wayland',
46}
47config.use_dead_keys = false
48config.warn_about_missing_glyphs = false
49config.window_decorations = "TITLE | RESIZE"
50config.window_padding = {
51 left = 0,
52 right = 0,
53 top = 0,
54 bottom = 0,
55}
56
57-- Tab bar
58config.use_fancy_tab_bar = true
59config.tab_bar_at_bottom = true
60config.switch_to_last_active_tab_when_closing_tab = true
61config.tab_max_width = 32
62config.colors = {
63 quick_select_label_bg = { Color = '#fdf6e3' },
64 quick_select_label_fg = { Color = '#073642' },
65 tab_bar = {
66 active_tab = {
67 fg_color = '#073642',
68 bg_color = '#2aa198',
69 }
70 }
71}
72
73-- Add items to launch menu
74config.launch_menu = {
75 {
76 label = 'mwop',
77 cwd = wezterm.home_dir .. '/git/weierophinney/mwop.net',
78 },
79 {
80 label = 'onedrive',
81 cwd = wezterm.home_dir .. '/OneDrive',
82 },
83 {
84 label = 'top',
85 args = { 'top' },
86 },
87}
88
89-- Custom key bindings
90config.keys = {
91 -- Show the launcher
92 {
93 key = 'm',
94 mods = 'LEADER',
95 action = act.ShowLauncher,
96 },
97
98 -- Copy mode
99 {
100 key = '[',
101 mods = 'LEADER',
102 action = act.ActivateCopyMode,
103 },
104
105 -- ----------------------------------------------------------------
106 -- TABS
107 --
108 -- Where possible, I'm using the same combinations as I would in tmux
109 -- ----------------------------------------------------------------
110
111 -- Show tab navigator; similar to listing panes in tmux
112 {
113 key = 'w',
114 mods = 'LEADER',
115 action = act.ShowTabNavigator,
116 },
117
118 -- Create a tab (alternative to Ctrl-Shift-Tab)
119 {
120 key = 'c',
121 mods = 'LEADER',
122 action = act.SpawnTab 'CurrentPaneDomain',
123 },
124
125 -- Rename current tab; analagous to command in tmux
126 {
127 key = ',',
128 mods = 'LEADER',
129 action = act.PromptInputLine {
130 description = 'Enter new name for tab',
131 action = wezterm.action_callback(
132 function(window, pane, line) -- luacheck: ignore 212
133 if line then
134 window:active_tab():set_title(line)
135 end
136 end
137 ),
138 },
139 },
140
141 -- Move to next/previous TAB
142 {
143 key = 'n',
144 mods = 'LEADER',
145 action = act.ActivateTabRelative(1),
146 },
147 {
148 key = 'p',
149 mods = 'LEADER',
150 action = act.ActivateTabRelative(-1),
151 },
152
153 -- Close tab
154 {
155 key = '&',
156 mods = 'LEADER|SHIFT',
157 action = act.CloseCurrentTab{ confirm = true },
158 },
159
160 -- ----------------------------------------------------------------
161 -- PANES
162 --
163 -- These are great and get me most of the way to replacing tmux
164 -- entirely, particularly as you can use "wezterm ssh" to ssh to another
165 -- server, and still retain Wezterm as your terminal there.
166 --
167 -- Note that these only define creating splits, relative motion
168 -- (next/previous), zooming, swapping, and killing panes; actual directional
169 -- motions between panes or resizing them are handled by smart splits.
170 -- ----------------------------------------------------------------
171
172 -- Vertical split
173 {
174 -- |
175 key = '|',
176 mods = 'LEADER|SHIFT',
177 action = act.SplitPane {
178 direction = 'Right',
179 size = { Percent = 50 },
180 },
181 },
182
183 -- Horizontal split
184 {
185 -- -
186 key = '-',
187 mods = 'LEADER',
188 action = act.SplitPane {
189 direction = 'Down',
190 size = { Percent = 50 },
191 },
192 },
193
194 -- Close/kill active pane
195 {
196 key = 'x',
197 mods = 'LEADER',
198 action = act.CloseCurrentPane { confirm = true },
199 },
200
201 -- Swap active pane with another one
202 {
203 key = '{',
204 mods = 'LEADER|SHIFT',
205 action = act.PaneSelect { mode = "SwapWithActiveKeepFocus" },
206 },
207
208 -- Zoom current pane (toggle)
209 {
210 key = 'z',
211 mods = 'LEADER',
212 action = act.TogglePaneZoomState,
213 },
214 {
215 key = 'f',
216 mods = 'ALT',
217 action = act.TogglePaneZoomState,
218 },
219
220 -- Move to next/previous pane
221 {
222 key = ';',
223 mods = 'LEADER',
224 action = act.ActivatePaneDirection('Prev'),
225 },
226 {
227 key = 'o',
228 mods = 'LEADER',
229 action = act.ActivatePaneDirection('Next'),
230 },
231
232 -- ----------------------------------------------------------------
233 -- Workspaces
234 --
235 -- These are roughly equivalent to tmux sessions.
236 -- ----------------------------------------------------------------
237
238 -- Attach to muxer
239 {
240 key = 'a',
241 mods = 'LEADER',
242 action = act.AttachDomain 'unix',
243 },
244
245 -- Detach from muxer
246 {
247 key = 'd',
248 mods = 'LEADER',
249 action = act.DetachDomain { DomainName = 'unix' },
250 },
251
252 -- Show list of workspaces
253 {
254 key = 's',
255 mods = 'LEADER',
256 action = act.ShowLauncherArgs { flags = 'WORKSPACES' },
257 },
258
259 -- Rename current session; analagous to command in tmux
260 {
261 key = '$',
262 mods = 'LEADER|SHIFT',
263 action = act.PromptInputLine {
264 description = 'Enter new name for session',
265 action = wezterm.action_callback(
266 function(window, pane, line) -- luacheck: ignore 212
267 if line then
268 mux.rename_workspace(
269 window:mux_window():get_workspace(),
270 line
271 )
272 end
273 end
274 ),
275 },
276 },
277}
278
279-- --------------------------------------------------------------------
280-- Smart splits
281--
282-- See https://github.com/mrjones2014/smart-splits.nvim
283--
284-- Allows moving and resizing panes easily, as well as navigation between
285-- wezterm and nvim panes
286-- --------------------------------------------------------------------
287config.keys = merge.all(config.keys, smart_splits.keys)
288
289-- --------------------------------------------------------------------
290-- resurrect.wezterm
291--
292-- See https://github.com/MLFlexer/resurrect.wezterm
293-- See resurrect.lua
294-- --------------------------------------------------------------------
295config.keys = merge.all(config.keys, resurrect.keys)
296
297-- Powerline for tab bar
298require 'powerline'
299
300-- Tab status
301require 'tab-status'
302
303-- Plugin management
304-- Automatically update plugins
305-- wezterm.plugin.update_all()
306
307-- and finally, return the configuration to wezterm
308return config