diff --git a/config/src/config.rs b/config/src/config.rs index f45676749..7ff37c316 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -325,8 +325,8 @@ pub struct Config { #[dynamic(default = "UnixDomain::default_unix_domains")] pub unix_domains: Vec, - #[dynamic(default = "SshDomain::default_domains")] - pub ssh_domains: Vec, + #[dynamic(default)] + pub ssh_domains: Option>, #[dynamic(default)] pub ssh_backend: SshBackend, @@ -828,6 +828,17 @@ impl Config { Self::load_with_overrides(&wezterm_dynamic::Value::default()) } + /// It is relatively expensive to parse all the ssh config files, + /// so we defer producing the default list until someone explicitly + /// asks for it + pub fn ssh_domains(&self) -> Vec { + if let Some(domains) = &self.ssh_domains { + domains.clone() + } else { + SshDomain::default_domains() + } + } + pub fn update_ulimit(&self) -> anyhow::Result<()> { #[cfg(unix)] { @@ -1127,8 +1138,10 @@ impl Config { for d in &self.unix_domains { check_domain(&d.name, "unix domain")?; } - for d in &self.ssh_domains { - check_domain(&d.name, "ssh domain")?; + if let Some(domains) = &self.ssh_domains { + for d in domains { + check_domain(&d.name, "ssh domain")?; + } } for d in &self.exec_domains { check_domain(&d.name, "exec domain")?; diff --git a/wezterm-gui/src/main.rs b/wezterm-gui/src/main.rs index c59158a24..c9e47ed52 100644 --- a/wezterm-gui/src/main.rs +++ b/wezterm-gui/src/main.rs @@ -250,7 +250,7 @@ fn client_domains(config: &config::ConfigHandle) -> Vec { domains.push(ClientDomainConfig::Unix(unix_dom.clone())); } - for ssh_dom in &config.ssh_domains { + for ssh_dom in config.ssh_domains().into_iter() { if ssh_dom.multiplexing == SshMultiplexing::WezTerm { domains.push(ClientDomainConfig::Ssh(ssh_dom.clone())); } @@ -341,7 +341,7 @@ fn update_mux_domains(config: &ConfigHandle) -> anyhow::Result<()> { mux.add_domain(&domain); } - for ssh_dom in &config.ssh_domains { + for ssh_dom in config.ssh_domains().into_iter() { if ssh_dom.multiplexing != SshMultiplexing::None { continue; }