1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 13:21:38 +03:00

ssh: fix handling wezterm ssh user@host:22

This commit is contained in:
Wez Furlong 2021-03-29 21:21:31 -07:00
parent 3ee86a2e8b
commit d45bbed3fd

View File

@ -89,11 +89,21 @@ enum SubCommand {
async fn async_run_ssh(opts: SshCommand) -> anyhow::Result<()> {
let mut ssh_config = Config::new();
ssh_config.add_default_config_files();
let mut ssh_config = ssh_config.for_host(&opts.user_at_host_and_port.host_and_port);
let mut fields = opts.user_at_host_and_port.host_and_port.split(':');
let host = fields
.next()
.ok_or_else(|| anyhow::anyhow!("no host component somehow"))?;
let port = fields.next();
let mut ssh_config = ssh_config.for_host(host);
ssh_config.insert(
"user".to_string(),
opts.user_at_host_and_port.username.to_string(),
);
if let Some(port) = port {
ssh_config.insert("port".to_string(), port.to_string());
}
for (k, v) in opts.config_override {
ssh_config.insert(k.to_lowercase().to_string(), v);
}