From 3593a288eaeab953484c48d8fc9f4d4ec7dbcf71 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 9 Jan 2022 19:16:54 -0700 Subject: [PATCH] ssh: rename use_multiplexer to multiplexing This puts us in a better position for the future to be able to configure whether we use wezterm, tmux or no multiplexing. Today we allow wezterm or no multiplexing. Add docs on this new setting. refs: https://github.com/wez/wezterm/issues/1456 --- config/src/ssh.rs | 18 ++++++++++++++++-- docs/config/lua/SshDomain.md | 26 ++++++++++++++++++++++++++ wezterm-gui/src/main.rs | 6 +++--- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/config/src/ssh.rs b/config/src/ssh.rs index a42526ec3..c53c638ab 100644 --- a/config/src/ssh.rs +++ b/config/src/ssh.rs @@ -15,6 +15,20 @@ impl Default for SshBackend { } } +#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)] +pub enum SshMultiplexing { + WezTerm, + None, + // TODO: Tmux-cc in the future? +} +impl_lua_conversion!(SshMultiplexing); + +impl Default for SshMultiplexing { + fn default() -> Self { + Self::WezTerm + } +} + #[derive(Default, Debug, Clone, Deserialize, Serialize)] pub struct SshDomain { /// The name of this specific domain. Must be unique amongst @@ -47,8 +61,8 @@ pub struct SshDomain { /// just connect directly using ssh. This doesn't require /// that the remote host have wezterm installed, and is equivalent /// to using `wezterm ssh` to connect. - #[serde(default = "default_true")] - pub use_multiplexer: bool, + #[serde(default)] + pub multiplexing: SshMultiplexing, /// ssh_config option values #[serde(default)] diff --git a/docs/config/lua/SshDomain.md b/docs/config/lua/SshDomain.md index 9ee092060..173bb6b05 100644 --- a/docs/config/lua/SshDomain.md +++ b/docs/config/lua/SshDomain.md @@ -54,3 +54,29 @@ return { } ``` +*Since: nightly builds only* + +You may now specify the type of `multiplexing` used by an ssh domain. +The following values are possible: + +* `"WezTerm"` - this is the default; use wezterm's multiplexing client. + Having wezterm installed on the server is required to use this mode. +* `"None"` - don't use any multiplexing. The connection is an ssh connection + using the same mechanism as is used by `wezterm ssh`; losing connectivity + will lose any panes/tabs. This mode of operation is convenient when using + SSH to connect automatically into eg: a locally hosted WSL instance, together + with the [default_domain](config/default_domain.md) option. + +```lua +return { + ssh_domains = { + { + name = "my.server", + remote_address = "192.168.1.1", + multiplexing = "None", + } + }, + + default_domain = "my.server", +} +``` diff --git a/wezterm-gui/src/main.rs b/wezterm-gui/src/main.rs index 5ce922f8c..2d20c4cbe 100644 --- a/wezterm-gui/src/main.rs +++ b/wezterm-gui/src/main.rs @@ -3,7 +3,7 @@ use ::window::*; use anyhow::{anyhow, Context}; -use config::{ConfigHandle, SshBackend}; +use config::{ConfigHandle, SshBackend, SshMultiplexing}; use mux::activity::Activity; use mux::domain::{Domain, LocalDomain}; use mux::ssh::RemoteSshDomain; @@ -211,7 +211,7 @@ fn client_domains(config: &config::ConfigHandle) -> Vec { } for ssh_dom in &config.ssh_domains { - if ssh_dom.use_multiplexer { + if ssh_dom.multiplexing == SshMultiplexing::WezTerm { domains.push(ClientDomainConfig::Ssh(ssh_dom.clone())); } } @@ -334,7 +334,7 @@ fn update_mux_domains(config: &ConfigHandle) -> anyhow::Result<()> { } for ssh_dom in &config.ssh_domains { - if ssh_dom.use_multiplexer { + if ssh_dom.multiplexing != SshMultiplexing::None { continue; }