mirror of
https://github.com/wez/wezterm.git
synced 2024-12-23 13:21:38 +03:00
ssh: allow setting default_prog for SshDomain when multiplexing=None
``` return { ssh_domains = { { name = "woot", remote_address = "192.168.1.8", multiplexing = "None", default_prog = {"fish"}, } }, default_domain = "woot", } ``` refs: https://github.com/wez/wezterm/issues/1456
This commit is contained in:
parent
a045cfe092
commit
b3987bec12
@ -67,6 +67,8 @@ pub struct SshDomain {
|
||||
/// ssh_config option values
|
||||
#[serde(default)]
|
||||
pub ssh_option: HashMap<String, String>,
|
||||
|
||||
pub default_prog: Option<Vec<String>>,
|
||||
}
|
||||
impl_lua_conversion!(SshDomain);
|
||||
|
||||
|
@ -74,9 +74,17 @@ return {
|
||||
name = "my.server",
|
||||
remote_address = "192.168.1.1",
|
||||
multiplexing = "None",
|
||||
|
||||
-- When multiplexing == "None", default_prog can be used
|
||||
-- to specify the default program to run in new tabs/panes.
|
||||
-- Due to the way that ssh works, you cannot specify default_cwd,
|
||||
-- but you could instead change your default_prog to put you
|
||||
-- in a specific directory.
|
||||
default_prog = {"fish"},
|
||||
}
|
||||
},
|
||||
|
||||
default_domain = "my.server",
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -196,6 +196,31 @@ impl RemoteSshDomain {
|
||||
pub fn ssh_config(&self) -> anyhow::Result<ConfigMap> {
|
||||
ssh_domain_to_ssh_config(&self.dom)
|
||||
}
|
||||
|
||||
fn build_command(
|
||||
&self,
|
||||
pane_id: PaneId,
|
||||
command: Option<CommandBuilder>,
|
||||
) -> anyhow::Result<(Option<String>, HashMap<String, String>)> {
|
||||
let config = config::configuration();
|
||||
let cmd = match command {
|
||||
Some(mut cmd) => {
|
||||
config.apply_cmd_defaults(&mut cmd, None);
|
||||
cmd
|
||||
}
|
||||
None => config.build_prog(None, self.dom.default_prog.as_ref(), None)?,
|
||||
};
|
||||
let mut env: HashMap<String, String> = cmd
|
||||
.iter_extra_env_as_str()
|
||||
.map(|(k, v)| (k.to_string(), v.to_string()))
|
||||
.collect();
|
||||
env.insert("WEZTERM_PANE".to_string(), pane_id.to_string());
|
||||
if cmd.is_default_prog() {
|
||||
Ok((None, env))
|
||||
} else {
|
||||
Ok((Some(cmd.as_unix_command_line()?), env))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Carry out the authentication process and create the initial pty.
|
||||
@ -485,21 +510,7 @@ impl Domain for RemoteSshDomain {
|
||||
) -> Result<Rc<Tab>, Error> {
|
||||
let pane_id = alloc_pane_id();
|
||||
|
||||
let cmd = match command {
|
||||
Some(c) => c,
|
||||
None => CommandBuilder::new_default_prog(),
|
||||
};
|
||||
|
||||
let command_line = if cmd.is_default_prog() {
|
||||
None
|
||||
} else {
|
||||
Some(cmd.as_unix_command_line()?)
|
||||
};
|
||||
let mut env: HashMap<String, String> = cmd
|
||||
.iter_extra_env_as_str()
|
||||
.map(|(k, v)| (k.to_string(), v.to_string()))
|
||||
.collect();
|
||||
env.insert("WEZTERM_PANE".to_string(), pane_id.to_string());
|
||||
let (command_line, env) = self.build_command(pane_id, command)?;
|
||||
|
||||
let pty: Box<dyn portable_pty::MasterPty>;
|
||||
let child: Box<dyn portable_pty::Child + Send>;
|
||||
@ -650,26 +661,8 @@ impl Domain for RemoteSshDomain {
|
||||
None => anyhow::bail!("invalid pane index {}", pane_index),
|
||||
};
|
||||
|
||||
let config = config::configuration();
|
||||
let cmd = match command {
|
||||
Some(mut cmd) => {
|
||||
config.apply_cmd_defaults(&mut cmd, None);
|
||||
cmd
|
||||
}
|
||||
None => config.build_prog(None, None, None)?,
|
||||
};
|
||||
let pane_id = alloc_pane_id();
|
||||
|
||||
let command_line = if cmd.is_default_prog() {
|
||||
None
|
||||
} else {
|
||||
Some(cmd.as_unix_command_line()?)
|
||||
};
|
||||
let mut env: HashMap<String, String> = cmd
|
||||
.iter_extra_env_as_str()
|
||||
.map(|(k, v)| (k.to_string(), v.to_string()))
|
||||
.collect();
|
||||
env.insert("WEZTERM_PANE".to_string(), pane_id.to_string());
|
||||
let (command_line, env) = self.build_command(pane_id, command)?;
|
||||
|
||||
let session = self
|
||||
.session
|
||||
|
Loading…
Reference in New Issue
Block a user