feat: add pre_connect hook and optional shortcut alias display
Test / test (pull_request) Successful in 4m27s

- 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:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-17 12:00:27 +01:00
1 parent 20d7a40543
commit 796925b1a2
15 files changed
+507 -23

No files matched your search

+10
View File
@@ -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
}