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

No files matched your search

+4 -1
View File
@@ -67,6 +67,9 @@ type ShortcutsConfig struct {
Domains []string `mapstructure:"domains"`
StripHyphens bool `mapstructure:"strip_hyphens"`
Rewrites []ShortcutRewrite `mapstructure:"rewrites"`
// Show displays each host's shortcut alias in the TUI and in host lists, and
// offers shortcuts in Tab completion even when the full name matches.
Show bool `mapstructure:"show"`
}
// ShortcutRewrite replaces every match of Pattern (Go regexp syntax) with
@@ -122,7 +125,7 @@ func Load() (*Config, error) {
v.SetEnvPrefix("NETSSH")
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
v.AutomaticEnv()
for _, key := range []string{"netbox.url", "netbox.token", "netbox.token_version", "resolver.strategies", "resolver.management_subnets", "resolver.interface_name", "resolver.hostname_domain", "cache.ttl", "cache.path", "ssh.default_user", "ssh.default_port", "shortcuts.domains", "shortcuts.strip_hyphens", "shell.alias", "ssh.proxy_jump", "ssh.host_key_checking", "ssh.target", "ssh.address_family", "completion.max_results", "multi.multiplexer", "multi.panes_per_window"} {
for _, key := range []string{"netbox.url", "netbox.token", "netbox.token_version", "resolver.strategies", "resolver.management_subnets", "resolver.interface_name", "resolver.hostname_domain", "cache.ttl", "cache.path", "ssh.default_user", "ssh.default_port", "shortcuts.domains", "shortcuts.strip_hyphens", "shortcuts.show", "shell.alias", "ssh.proxy_jump", "ssh.pre_connect", "ssh.host_key_checking", "ssh.target", "ssh.address_family", "completion.max_results", "multi.multiplexer", "multi.panes_per_window"} {
if err := v.BindEnv(key); err != nil {
return nil, err
}