Skip to content

A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.

fix(config): apply window overrides when there is no config file

RoversX7c1113c0f519
diff --git a/config/src/config.rs b/config/src/config.rs
index f66d261b..30fcf40e 100644
--- a/config/src/config.rs
+++ b/config/src/config.rs
@@ -1199,7 +1199,7 @@ impl Config {
std::env::remove_var("WEZTERM_CONFIG_FILE");
std::env::remove_var("WEZTERM_CONFIG_DIR");
- match Self::try_default() {
+ match Self::try_default_with_overrides(overrides) {
Err(err) => LoadedConfig {
config: Err(err),
file_name: None,
@@ -1211,9 +1211,15 @@ impl Config {
}
pub fn try_default() -> anyhow::Result<LoadedConfig> {
+ Self::try_default_with_overrides(&wezterm_dynamic::Value::default())
+ }
+
+ fn try_default_with_overrides(
+ overrides: &wezterm_dynamic::Value,
+ ) -> anyhow::Result<LoadedConfig> {
let (config, warnings) =
wezterm_dynamic::Error::capture_warnings(|| -> anyhow::Result<Config> {
- Ok(default_config_with_overrides_applied()?.compute_extra_defaults(None))
+ Ok(default_config_with_overrides_applied(overrides)?.compute_extra_defaults(None))
});
Ok(LoadedConfig {
@@ -2732,6 +2738,29 @@ return config
);
}
+ #[test]
+ fn default_config_applies_window_overrides() {
+ use wezterm_dynamic::ToDynamic;
+ let mut overrides = wezterm_dynamic::Object::default();
+ overrides.insert(
+ "color_scheme".to_dynamic(),
+ "Builtin Solarized Light".to_dynamic(),
+ );
+ overrides.insert(
+ "window_background_opacity".to_dynamic(),
+ 0.7f64.to_dynamic(),
+ );
+
+ let loaded =
+ Config::try_default_with_overrides(&wezterm_dynamic::Value::Object(overrides)).unwrap();
+ let config = loaded.config.unwrap();
+ assert_eq!(
+ config.color_scheme.as_deref(),
+ Some("Builtin Solarized Light")
+ );
+ assert_eq!(config.window_background_opacity, 0.7);
+ }
+
#[test]
fn active_config_candidates_do_not_auto_load_upstream_wezterm_configs() {
let home = std::path::Path::new("/home/example");
diff --git a/config/src/lib.rs b/config/src/lib.rs
index 418e33d7..d6a58216 100644
--- a/config/src/lib.rs
+++ b/config/src/lib.rs
@@ -416,11 +416,18 @@ where
promise::spawn::spawn_into_main_thread(async move { schedule_with_lua(func).await }).await
}
-fn default_config_with_overrides_applied() -> anyhow::Result<Config> {
+fn default_config_with_overrides_applied(
+ overrides: &wezterm_dynamic::Value,
+) -> anyhow::Result<Config> {
// Cause the default config to be re-evaluated with the overrides applied
let lua = lua::make_lua_context(Path::new("override")).context("make_lua_context")?;
let table = mlua::Value::Table(lua.create_table()?);
let config = Config::apply_overrides_to(&lua, table).context("apply_overrides_to")?;
+ // Then a window's own, as `try_load` applies them over a file. Settings'
+ // colour scheme and opacity are window overrides, and must apply with
+ // no config file too.
+ let config = Config::apply_overrides_obj_to(&lua, config, overrides)
+ .context("apply_overrides_obj_to")?;
let dyn_config = luahelper::lua_value_to_dynamic(config)?;
@@ -515,7 +522,7 @@ pub fn set_config_file_override(path: &Path) {
pub fn set_config_overrides(items: &[(String, String)]) -> anyhow::Result<()> {
*CONFIG_OVERRIDES.lock().unwrap() = items.to_vec();
- let _ = default_config_with_overrides_applied()?;
+ let _ = default_config_with_overrides_applied(&wezterm_dynamic::Value::default())?;
Ok(())
}