1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-01 09:13:10 +03:00
wezterm/docs/config/lua/SshDomain.md
Wez Furlong 1357480ce6 SshDomain: add assume_unix option; enables setting cwd for new panes
If we know that the remote host is a unix system, and that it uses some
version of the posix shell, then we can adjust our command line to cd to
the requested directory (as set by OSC 7) and then exec the requested
command.

That's what SshDomain::assume_unix indicates and what this commit does.
2022-01-09 21:32:09 -07:00

3.1 KiB

SshDomain

The SshDomain struct specifies information about an individual SSH Domain.

It is a lua object with the following fields:

{
    -- The name of this specific domain.  Must be unique amongst
    -- all types of domain in the configuration file.
    name = "my.server",

    -- identifies the host:port pair of the remote server
    -- Can be a DNS name or an IP address with an optional
    -- ":port" on the end.
    remote_address = "192.168.1.1",

    -- Whether agent auth should be disabled.
    -- Set to true to disable it.
    -- no_agent_auth = false,

    -- The username to use for authenticating with the remote host
    username = "yourusername",

    -- If true, connect to this domain automatically at startup
    -- connect_automatically = true,

    -- Specify an alternative read timeout
    -- timeout = 60,

    -- The path to the wezterm binary on the remote host.
    -- Primarily useful if it isn't installed in the $PATH
    -- that is configure for ssh.
    -- remote_wezterm_path = "/home/yourusername/bin/wezterm"
}

Since: 20220101-133340-7edc5b5a

You may now specify a table with ssh config overrides:

return {
  ssh_domains = {
    {
      name = "my.server",
      remote_address = "192.168.1.1",
      ssh_option = {
        identityfile = "/path/to/id_rsa.pub",
      }
    }
  }
}

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 option.

A new assume_unix option, when coupled with multiplexing = "None", allows wezterm to assume that the remote host uses some version of the posix shell command language by default, which in turn allows wezterm to respect the current working directory as set by OSC 7 / Shell Integration on the remote host when spawning new panes and tabs.

return {
  ssh_domains = {
    {
      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"},

      -- assume that we can use syntax like:
      -- "cd /some/where ; exec $SHELL"
      -- using whatever the default command shell is on this
      -- remote host, so that shell integration will respect
      -- the current directory on the remote host.
      assume_unix = true,
    }
  },

  default_domain = "my.server",
}