feat: add pre_connect hook and optional shortcut alias display
- ssh.pre_connect: local shell command run before every connection, layered like proxy_jump (global, instance/static host, rules; "none" disables). Host details are passed as NETSSH_* env vars, a non-zero exit aborts the connection, --dry-run only prints it. - shortcuts.show: show shortcut aliases in the TUI host list, an ALIAS column in `cache list` / `hosts list` (also via --aliases) and in Tab completion. - Both editable in `netssh configure`; README and CHANGELOG updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAuVpPncumMViLLc8N4
This commit is contained in:
1 parent
3804c33669
commit
419c682a71
15 files changed
+507
-23
No files matched your search
@@ -23,6 +23,7 @@ func editSSHOptions(title string, o config.SSHOptions) (config.SSHOptions, error
|
||||
extraArgs := strings.Join(o.ExtraArgs, "\n")
|
||||
options := formatOptions(o.Options)
|
||||
forwards := formatForwards(o.Forwards)
|
||||
preConnect := o.PreConnect
|
||||
|
||||
err := huh.NewForm(huh.NewGroup(
|
||||
huh.NewInput().
|
||||
@@ -69,6 +70,14 @@ func editSSHOptions(title string, o config.SSHOptions) (config.SSHOptions, error
|
||||
_, err := parseForwards(s)
|
||||
return err
|
||||
}),
|
||||
huh.NewInput().
|
||||
Title("Pre-connect hook").
|
||||
Description("Shell command run locally before connecting, e.g. vpn-check.sh \"$NETSSH_HOST\".\n"+
|
||||
"A non-zero exit aborts. Leave empty to inherit; 'none' disables a hook set elsewhere.").
|
||||
Value(&preConnect).
|
||||
Validate(func(s string) error {
|
||||
return config.SSHOptions{PreConnect: s}.Validate("ssh")
|
||||
}),
|
||||
).Title(title)).Run()
|
||||
if err != nil {
|
||||
return o, err
|
||||
@@ -84,6 +93,7 @@ func editSSHOptions(title string, o config.SSHOptions) (config.SSHOptions, error
|
||||
AddressFamily: addressFamily,
|
||||
ExtraArgs: parseLines(extraArgs),
|
||||
Options: parsed,
|
||||
PreConnect: strings.TrimSpace(preConnect),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user