Closed DavidRR-F closed 1 month ago
So I have done some research and found a possible method of "faking" ssh domain splits via exec_domains.
It should be possible parse the config ssh domains to either have one exec_domain for each ssh config, or have the cmd args to a single exec_domain contain the nessisary ssh command. I think the latter is the cleanest solution
config.exec_domains = {
wezterm.exec_domain("exec", function(cmd)
cmd.args = { "ssh", "mlflexer@192.168.0.42" }
return cmd
end),
}
config.keys = {
{
key = "-",
mods = "CTRL",
action = wezterm.action_callback(function(window, pane)
pane:split({ domain = { DomainName = "exec" } })
end),
},
}
Oh Interesting. So these exec_domains
get handled differently than remote domains do. The remote domains (ssh, tls, and unix) essentially use wezterm connect
which uses the selected protocol to connect to a remote wezterm instance running on the server which allows for multiplexing in the same window without making a new connection. So technically you could just expand on the ssh doc like this:
local wezterm = require 'wezterm'
local ssh_domains = {}
local exec_domains = {}
for host, config in pairs(wezterm.enumerate_ssh_hosts()) do
table.insert(ssh_domains, {
name = host,
remote_address = host,
--assume_shell = 'Posix',
})
table.insert(exec_domains,
wezterm.exec_domain(
"exec: " .. host,
function(cmd)
cmd.args = { "ssh", config.user .. "@" .. config.hostname }
return cmd
end
)
)
end
return {
ssh_domains = ssh_domains,
exec_domains = exec_domains,
}
This would add the exec_domains to your list of domains that are usable in the split commands and you would have both the ssh_domain
and exec_domain
for spawning in the new tab or exclude ssh_domain
if you have no need to multiplexing on a remote server.
Or I could add a piece to the apply_config
that would add the exec_domain
for each ssh_domain
defined in the user config, but this would remove the ability to exclude the ssh_domains (which require a remote wezterm instance)
What are your thoughts?
I figured it out. I have added configuration options to automate the configuration of ssh and exec domains this should will allow splitting panes into an ssh session
{
keys = ...,
icons = ...,
auto = {
ssh_ignore = false,
exec_ignore = {
ssh = false,
docker = true,
kubernetes = true
},
}
}
Problem: Default wezterm split pane actions do not support splitting panes with remote domains
Feature: Configure split pane keybinds with remote domain switching either with MuxDomain attach (if possible) or find domain infomation and run native command in SpawnCommand (i.e. ssh username>@<hostname etc,,,)
Maybe something like this could work: