feat: add pre_connect hook and optional shortcut alias display #43

Merged
Sebi merged 1 commits from feat/pre-connect-hook-alias-display into main 2026-11-17 11:11:35 +00:00
Owner

Changes

  • ssh.pre_connect: a local shell command (sh -c) runs before every connection (ssh, sftp, scp, tunnel), e.g. to check a VPN.
    • Layering works like proxy_jump: global → instance or static host → rules. none disables an inherited hook.
    • The hook gets NETSSH_HOST, NETSSH_TARGET, NETSSH_INSTANCE, NETSSH_IP, NETSSH_KIND, NETSSH_TAGS and NETSSH_CLIENT.
    • Its output goes to stderr. A non-zero exit aborts the connection. --dry-run only prints the hook.
  • shortcuts.show: shows shortcut aliases in three places:
    • the TUI host list (→ alias)
    • an ALIAS column in netssh cache list and netssh hosts list; --aliases shows it for a single call
    • Tab completion
  • Both settings can be edited in netssh configure and set through env vars (NETSSH_SSH_PRE_CONNECT, NETSSH_SHORTCUTS_SHOW).
  • README and CHANGELOG (v0.0.29) are updated.

Tests

  • gofmt, go vet and go test -count=1 ./... pass.
  • Tested end-to-end with an isolated config:
    • the hook runs, and a failing hook ends with exit 1
    • none set by a rule takes effect
    • with --dry-run the hook is not run
    • lists, completion and the TUI (rendered in tmux) work

🤖 Generated with Claude Code

https://claude.ai/code/session_017GpWAuVpPncumMViLLc8N4

## Changes - **`ssh.pre_connect`**: a local shell command (`sh -c`) runs before every connection (ssh, sftp, scp, tunnel), e.g. to check a VPN. - Layering works like `proxy_jump`: global → instance or static host → rules. `none` disables an inherited hook. - The hook gets `NETSSH_HOST`, `NETSSH_TARGET`, `NETSSH_INSTANCE`, `NETSSH_IP`, `NETSSH_KIND`, `NETSSH_TAGS` and `NETSSH_CLIENT`. - Its output goes to stderr. A non-zero exit aborts the connection. `--dry-run` only prints the hook. - **`shortcuts.show`**: shows shortcut aliases in three places: - the TUI host list (`→ alias`) - an `ALIAS` column in `netssh cache list` and `netssh hosts list`; `--aliases` shows it for a single call - Tab completion - Both settings can be edited in `netssh configure` and set through env vars (`NETSSH_SSH_PRE_CONNECT`, `NETSSH_SHORTCUTS_SHOW`). - README and CHANGELOG (v0.0.29) are updated. ## Tests - `gofmt`, `go vet` and `go test -count=1 ./...` pass. - Tested end-to-end with an isolated config: - the hook runs, and a failing hook ends with exit 1 - `none` set by a rule takes effect - with `--dry-run` the hook is not run - lists, completion and the TUI (rendered in tmux) work 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017GpWAuVpPncumMViLLc8N4
Sebi added 1 commit 2026-11-17 11:00:46 +00:00
feat: add pre_connect hook and optional shortcut alias display
Test / test (pull_request) Successful in 4m27s
796925b1a2
- 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
Sebi merged commit 835b6b48cd into main 2026-11-17 11:11:35 +00:00
Sebi deleted branch feat/pre-connect-hook-alias-display 2026-11-17 11:11:37 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Sebi/ssh-netbox-wrapper#43