You are just moving to WezTerm and you want to do something vaguely troublesome with your WezTerm config and split it into multiple files which you can maybe keep in a central place with other config files? This is what I did.
My intent is to port this config to work similarly on MacOS in Zsh, but I'm starting on Windows 11 in PowerShell. I first have a single config file in one of WezTerm's expected config locations, in my case that was C:\Users\$USER\.config\wezterm\wezterm.lua (but I could have put it in C:\Users\$USER\.wezterm.lua or the WezTerm program folder directly) and since I irrationally hate everything it contains the following.
local wezterm = require 'wezterm'local config ={}if wezterm.config_builder then
config = wezterm.config_builder()end
Then at the end I, of course, return the config table.
Once I have that file in place I can create the custom Lua modules in one of WezTerm submodule folder locations. In my case that was C:\Users\$USER\.config\wezterm\windows.lua, for example. That file looks like the following.
local wezterm = require 'wezterm'local module ={}
First we define the standard wezterm and then initialize the module table, which we will eventually return.
Next I define module's apply_to_config function, which will load the locally defined variables into the .wezterm.lua's config table and thus affect our terminal. In this specific example I'm changing the default shell and inserting two entries in to the launch menu.[2]
return module
Lastly we return the module table.
You can define arbitrary many custom modules (and you may not necessarily want to organize them the way I did). Is this all a good idea? Not for me to say, but probably not. Why not just do one big config file? Good question.
Can't say as I've thought very hard about the way this is configured. Maybe the conditional should happen in the windows.lua file. ↩︎
You can see here I'm defining local variables first, assigning their values, then assigning them to the corresponding record in the config table. I don't necessarily need to do that, I could just assign to the config table directly. ↩︎