Compare commits

..
Author SHA1 Message Date
Sebastian Unterschütz c58b26ecf8 feat(multi): keep hotkeys visible and add README cheat sheet 2026-11-16 20:59:35 +01:00
Sebi c4466067a5 Merge pull request 'v0.0.24' (#40) from release/v0.0.24 into main
Release / release (push) Successful in 5m14s
2026-11-14 12:56:51 +00:00
Sebastian UnterschützandClaude Opus 5.5 3cacbb34d4 docs: changelog for v0.0.24
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 13:56:13 +01:00
Sebi b3de5c14f9 Merge pull request 'netssh multi: several servers in one window (tmux/zellij)' (#37) from feat/multi into main 2026-11-14 12:36:50 +00:00
Sebi 8b15ba18d2 Merge pull request 'Docker test environment + 3 bug fixes' (#36) from test/docker-env into main 2026-11-14 12:35:36 +00:00
Sebastian UnterschützandClaude Opus 5.5 5f04188fb4 feat(multi): tmux keys to toggle broadcast and exclude single panes
In windows opened by netssh multi, prefix S toggles broadcast for all
panes and prefix e excludes the current pane (a pane-level
synchronize-panes off, shown as [SOLO] in the border) or includes it
again. netssh sync --pane does the same from a shell.

S and e are unbound in a default tmux (E would be "spread evenly").
netssh writes the bindings to a small tmux config and sources it, binds
a key only if the user's tmux.conf does not use it (netssh's own earlier
binding is refreshed), and the bindings act only in windows marked
@netssh. multi.sync_key and multi.solo_key change the keys or turn them
off (none); also in the configurator. zellij syncs whole tabs only, so
excluding a pane is tmux-only.

testenv: the render test presses the keys through the xterm client
(send-keys -K) and checks [SOLO], that broadcast skips the excluded
pane, that S toggles, and that other windows are unaffected. The client
gets GNU grep: BusyBox grep -oF counted only one match per line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 13:32:32 +01:00
Sebastian UnterschützandClaude Opus 5.5 6bdbf9411d test: check what a real terminal renders for multi, zellij, and the TUI
tests/16-render.sh runs tmux, zellij, and the TUI in xterm on Xvfb,
takes screenshots, and reads them back with tesseract: remote prompts
in all panes, borders and titles with the hosts, [SYNC] appearing and
disappearing, panes side by side, broadcast output in every pane and
input in one pane only without it, windows split by panes_per_window,
the status bar, and TUI marks. Screenshots stay in testenv/.artifacts.

OCR reads three preprocessing variants (plain, stretched for dim gray,
brightest channel for colored text) and normalizes characters that
DejaVu Sans Mono makes ambiguous (1/l, C/().

The screenshots showed tmux cutting the session name in the status bar
to "[netssh-pv"; netssh multi now widens status-left-length for its
own session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 13:14:34 +01:00
Sebastian UnterschützandClaude Opus 5.5 e843c47bfa feat: netssh multi — several hosts side by side in tmux or zellij
netssh multi opens one pane per host in a tmux window or zellij tab.
Hosts come from names, tag:TAG (NetBox and static hosts), cluster:NAME
(NetBox virtualization clusters; devices by default, --kind vm|all),
and groups from the config (@name, nested, with cycle detection).
Every pane runs netssh HOST, so lookup, rules, and jump hosts apply.

- tmux: a new window inside tmux, else a new session that is attached;
  tiled layout, pane borders with the host and a [SYNC] marker.
- zellij: a generated grid layout; a new tab inside zellij, else a new
  session.
- --sync broadcasts typing to all panes; netssh sync toggles it in the
  current tmux window or zellij tab.
- TUI: Space marks hosts, Ctrl+A marks all, Enter opens them together.
- Configurator: multiplexer, panes per window, groups.

NetBox SearchAll gains a cluster filter (name to cluster IDs per
instance), and cache entries keep the host's cluster for completion
and an offline fallback. Panes skip the 24-hour background refresh
(checked once by multi) and get HOME/XDG paths but no NETSSH_* values,
which would expose tokens in the process list.

testenv/tests/15-multi.sh checks real tmux and zellij sessions,
including a broadcast command arriving on all three cluster nodes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 12:45:05 +01:00
Sebastian UnterschützandClaude Opus 5.5 95eb424fea test: add a local Docker test environment for all features
testenv/ starts two real NetBox 4.7 instances (v2 and v1 token), SSH
targets on public, mgmt, and prod networks, a jump host, an IPv6-only
host, a static host, and a client with ssh, sftp, scp, tmux, zellij,
bash, zsh, and fish. A seed script fills NetBox through the REST API.

141 end-to-end checks cover cache and refresh filters, connecting,
all resolver strategies, multiple instances, shortcuts and rewrites,
SSH options and rules, static hosts, sftp/scp incl. IPv6 and jump
hosts, tunnels, local notes and NetBox comments, completion and shell
hooks, the TUI (driven through tmux), the configurator, and uninstall.

Local only: testenv/up.sh, test.sh, shell.sh, down.sh. Not part of
CI/CD.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 12:30:24 +01:00
Sebastian UnterschützandClaude Opus 5.5 b88a41f024 fix: interface_name strategy, instance hosts in sftp/scp, alias rewrites
Found by the new Docker test environment against a real NetBox 4.7:

- The interface_name strategy filtered IP addresses with interface_name
  and vminterface_name, which NetBox ignores, so it returned the first
  address of the host instead of the named interface's. Use the real
  filters interface and vminterface; a missing interface (HTTP 400)
  falls through to the next strategy.
- sftp and scp took instance-qualified hosts (prod/web01:/path) for
  local paths, because a "/" comes before the ":". Such arguments are
  remote when the prefix is a configured NetBox instance.
- Shell aliases of instance-qualified hosts ran the shortcut rules on
  "instance/host", so anchored rewrite rules never matched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 12:30:24 +01:00
Sebi fb6d2f3cfb Merge pull request 'Hostname strategy and static hosts' (#35) from feat/hostname-static-hosts into main
Release / release (push) Successful in 7m38s
2026-11-13 22:49:14 +00:00
Sebastian UnterschützandClaude Opus 5.5 4ff5e549cd feat: hostname resolver strategy and static hosts
Add the hostname resolver strategy. It connects by the NetBox name
instead of an IP, with resolver.hostname_domain appended to names
without a dot. Its position in the chain decides whether it is always
used or only as a fallback (e.g. [primary_ip, hostname]); names that
are not valid DNS hostnames fall through to the next strategy.

Add static hosts under hosts: for machines that are not in NetBox,
with address, user, port, tags, and their own SSH options. They are
checked before NetBox (by name or shortcut), never expire, survive
cache refresh and clear, and work without any NetBox configured. The
cache overlays them after every load and stores only their last use,
so they appear in completion, aliases, the TUI and its recent list.
SSH options merge global, static host, then rules; rules can match
kind: static. Manage them with netssh hosts list|add|remove and in
netssh configure, which can now also continue without NetBox.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 23:46:13 +01:00
Sebi f20d28ac41 Merge pull request 'docs: more detailed README' (#34) from docs/readme-details into main 2026-11-13 22:31:12 +00:00
Sebastian UnterschützandClaude Opus 5.5 653dacd6e3 docs: expand README with reference, recipes, and troubleshooting
Add a table of contents, a quick start, a full configuration reference
with defaults, the environment variables, a table of files and
directories, a command overview, details on rule matching and how
option layers combine (with real --dry-run output), recipes, a
troubleshooting table, and the project layout. Update How it works for
sftp, scp, tunnel, and forwards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 23:30:23 +01:00
Sebi 52bd2c3286 Merge pull request 'chore(renovate): no major updates of indirect Go modules' (#33) from chore/renovate-no-indirect-major into main 2026-11-13 22:25:28 +00:00
Sebastian UnterschützandClaude Opus 5.5 d3802e1a37 chore(renovate): skip major updates of indirect Go modules
A new major version of a Go module is a separate module path. For an
indirect dependency nothing imports it, so Renovate only adds an unused
requirement, as in #24 (go.yaml.in/yaml/v3 to v4). Minor and patch
updates of indirect modules stay enabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 23:24:31 +01:00
Sebi 12a8fd079a Merge pull request 'chore(deps): update module go.yaml.in/yaml/v3 to v3.0.6' (#23) from renovate/go.yaml.in-yaml-v3-3.x into main 2026-11-13 22:22:23 +00:00
Sebastian Unterschütz ef0dd63dff Merge remote-tracking branch 'origin/main' into work-23
# Conflicts:
#	go.mod
#	go.sum
2026-11-13 23:21:53 +01:00
Sebi a11a3bec97 Merge pull request 'chore(deps): update module github.com/xo/terminfo to v1.3.1' (#22) from renovate/github.com-xo-terminfo-1.x into main 2026-11-13 22:21:34 +00:00
Sebastian Unterschütz 5862a91dca Merge remote-tracking branch 'origin/main' into work-22 2026-11-13 23:21:03 +01:00
Sebi 2f7b4e76c6 Merge pull request 'chore(deps): update module github.com/spf13/pflag to v1.1.0' (#25) from renovate/github.com-spf13-pflag-1.x into main 2026-11-13 22:20:26 +00:00
Sebastian Unterschütz 64182a2acd Merge remote-tracking branch 'origin/main' into work-25 2026-11-13 23:19:44 +01:00
Sebi 6104a4773a Merge pull request 'chore(deps): update module golang.org/x/text to v0.44.0' (#29) from renovate/golang.org-x-text-0.x into main 2026-11-13 22:18:52 +00:00
Sebastian Unterschütz 7910e42759 Merge remote-tracking branch 'origin/main' into work-29
# Conflicts:
#	go.sum
2026-11-13 23:18:04 +01:00
Sebi d85d1d8097 Merge pull request 'fix(deps): update module golang.org/x/sys to v0.50.0' (#27) from renovate/golang.org-x-sys-0.x into main 2026-11-13 22:17:44 +00:00
Sebastian Unterschütz f75ff9d0a3 Merge remote-tracking branch 'origin/main' into work-27 2026-11-13 23:17:15 +01:00
Sebi 3f8d5dbdac Merge pull request 'fix(deps): update module charm.land/lipgloss/v2 to v2.1.0' (#28) from renovate/charm.land-lipgloss-v2-2.x into main 2026-11-13 22:16:38 +00:00
Sebastian Unterschütz 56fb9901bd Merge remote-tracking branch 'origin/main' into work-28 2026-11-13 23:16:05 +01:00
Sebi 3452120772 Merge pull request 'fix(deps): update module charm.land/bubbletea/v2 to v2.1.1' (#21) from renovate/charm.land-bubbletea-v2-2.x into main 2026-11-13 22:15:25 +00:00
Sebastian Unterschütz 1e40b1b405 Merge remote-tracking branch 'origin/main' into work-21 2026-11-13 23:14:56 +01:00
Sebi ddb053596c Merge pull request 'chore(deps): update go module directive to v1.27.4' (#30) from renovate/go-1.x into main 2026-11-13 22:13:41 +00:00
Sebastian Unterschütz 540c9f2b83 Merge remote-tracking branch 'origin/main' into work-30 2026-11-13 23:13:04 +01:00
Sebi 6ea91956fe Merge pull request 'SFTP, SCP, and named port forwards' (#32) from feat/sftp-forwarding into main 2026-11-13 22:08:48 +00:00
Sebi 10d2b48e4d Merge pull request 'v0.0.23: configurator for all options, regex shortcuts' (#31) from feat/configure-all-options into main 2026-11-13 22:07:45 +00:00
3 changed files with 159 additions and 21 deletions

No files matched your search

+99 -16
View File
@@ -22,6 +22,7 @@ The same lookup drives `netssh sftp`, `netssh scp`, and `netssh tunnel`, the int
- [Quick start](#quick-start)
- [Configuration](#configuration) — [wizard](#interactive-wizard), [manual config](#manual-config), [reference](#configuration-reference), [environment variables](#environment-variables), [files](#files-and-directories), [multiple instances](#multiple-netbox-instances)
- [Usage](#usage) — [command overview](#command-overview), [SSH options](#ssh-options), [SFTP & SCP](#sftp-and-scp), [port forwarding](#port-forwarding), [static hosts](#static-hosts), [multiple servers](#multiple-servers-in-one-window), [shortcuts](#host-shortcuts), [TUI](#interactive-tui), [notes](#server-notes), [cache](#cache-management)
- [Hotkey cheat sheet](#hotkey-cheat-sheet) — search, editors, tmux and zellij
- [Recipes](#recipes)
- [IP Resolution Strategies](#ip-resolution-strategies)
- [Shell Completion](#shell-completion) and [Shell Hook](#shell-hook)
@@ -597,7 +598,9 @@ multi:
| Exclude one pane | `Ctrl+b e` (again: include) or `netssh sync --pane` | not possible — zellij syncs whole tabs |
| Shown in the border | `[SYNC]` receives broadcast, `[SOLO]` excluded | `(SYNC)` in the tab name |
**Keys in tmux.** `S` and `e` are free in a default tmux (`E` would be "spread panes evenly"). netssh binds them after your prefix when it opens panes, but only if your own `tmux.conf` does not already use them — then it keeps your binding and says so. They act only in windows opened by `netssh multi`; elsewhere they just show a message. Change or turn them off with `multi.sync_key` / `multi.solo_key` (`none`), e.g. `sync_key: C-s` for `prefix Ctrl+s`.
**Keys in tmux.** The active pane border keeps the available broadcast/solo keys visible after attaching. See the [hotkey cheat sheet](#hotkey-cheat-sheet) for navigation and editor keys.
`S` and `e` are free in a default tmux (`E` would be "spread panes evenly"). netssh binds them after your prefix when it opens panes, but only if your own `tmux.conf` does not already use them — then it keeps your binding and says so. They act only in windows opened by `netssh multi`; elsewhere they just show a message. Change or turn them off with `multi.sync_key` / `multi.solo_key` (`none`), e.g. `sync_key: C-s` for `prefix Ctrl+s`.
**In the TUI**, mark hosts with `Space` (or all listed hosts with `Ctrl+A`) and press `Enter` to open them together.
@@ -714,21 +717,7 @@ netssh
The TUI opens with your 10 most-recently-connected hosts. Start typing to search all cached hosts or query NetBox live.
| Key | Action |
|-----|--------|
| type | filter hosts (300 ms debounce → NetBox query) |
| `Tab` | autocomplete top result into the search field |
| `↑` / `↓` | navigate results |
| `Enter` | connect to selected host |
| `Space` | mark/unmark the host; with marks, `Enter` opens them side by side (`netssh multi`) |
| `Ctrl+A` | mark all listed hosts (again: unmark all) |
| `Ctrl+O` | open an SFTP session to the selected host |
| `Ctrl+T` | start a tunnel: enter forward names or specs (`web, 8080:localhost:80`) |
| `Ctrl+E` | open inline editor to override user/port before connecting |
| `Ctrl+N` | edit local notes for the selected server |
| `Ctrl+B` | edit NetBox comments for the selected server |
| `Ctrl+F` | open/close tag and kind filter (`tag:prod kind:vm`) |
| `Esc` / `Ctrl+C` | quit (or close filter/edit if open) |
See the [hotkey cheat sheet](#hotkey-cheat-sheet) for all search and editor keys.
**Tag and kind filter** — press `Ctrl+F` to open a second input line:
@@ -817,6 +806,100 @@ The hook is a no-op when the cache is fresh — it adds no measurable delay to y
netssh search app- # prints matching hostnames, one per line
```
## Hotkey cheat sheet
Keys depend on the current screen: for example, `Ctrl+B` opens NetBox comments
in the search, while tmux uses `Ctrl+b` as its default prefix.
“Then” means release the first combination before pressing the next key;
`S` is uppercase (`Shift+s`).
### Search and host selection
| Key | Action |
|-----|--------|
| type | filter hosts (300 ms debounce → NetBox query) |
| `Tab` | autocomplete top result into the search field |
| `↑` / `↓` | navigate results |
| `PageUp` / `PageDown` | previous/next results page |
| `Home` / `End` | first/last result (also moves the search cursor) |
| `Enter` | connect to selected host |
| `Space` | mark/unmark the host; with marks, `Enter` opens them side by side (`netssh multi`) |
| `Ctrl+A` | mark all listed hosts (again: unmark all) |
| `Ctrl+O` | open an SFTP session to the selected host |
| `Ctrl+T` | start a tunnel: enter forward names or specs (`web, 8080:localhost:80`) |
| `Ctrl+E` | open inline editor to override user/port before connecting |
| `Ctrl+N` | edit local notes for the selected server |
| `Ctrl+B` | edit NetBox comments for the selected server |
| `Ctrl+F` | open/close tag and kind filter (`tag:prod kind:vm`) |
| `Esc` | quit search |
| `Ctrl+C` | quit from any TUI mode, including editors |
### Filters, connection/tunnel editors and notes
| Screen | Key | Action |
|---|---|---|
| Filter (`Ctrl+F`) | `Enter` | apply filter and return to results |
| Filter | `Esc` / `Ctrl+F` | close and clear the filter |
| User/port editor (`Ctrl+E`) | `Enter` | connect using the edited user/port |
| Tunnel editor (`Ctrl+T`) | `Enter` | start the requested forwards |
| User/port or tunnel editor | `Esc` | cancel and return to results |
| Local notes / NetBox comments | `Enter` | insert a new line |
| Local notes / NetBox comments | `Ctrl+S` | save |
| Local notes / NetBox comments | `Esc` | cancel and discard unsaved edits (when not loading/saving) |
| Any TUI screen | `Ctrl+C` | quit, discarding unsaved edits |
Text fields also support their standard cursor movement and editing keys.
### Multi-mode: tmux
The active pane's top border shows the configured broadcast/solo shortcuts
throughout the session. A narrow pane may clip the legend; zoom it with
`Ctrl+b` then `z` to make more room. `[SYNC]` means the pane receives broadcast;
`[SOLO]` means it is excluded.
The following uses tmux's default prefix `Ctrl+b`. Use your own prefix if
changed in `tmux.conf`; netssh's legend reads the configured prefix.
Navigation keys below are tmux defaults and can be remapped by your configuration.
| Key | Action |
|---|---|
| `Ctrl+b` then `S` | toggle broadcast for the current window (netssh default) |
| `Ctrl+b` then `e` | exclude/include the active pane in broadcast (netssh default) |
| `Ctrl+b` then arrow key | focus the pane in that direction |
| `Ctrl+b` then `o` | focus the next pane |
| `Ctrl+b` then `z` | zoom/unzoom the active pane |
| `Ctrl+b` then `n` / `p` | next/previous window |
| `Ctrl+b` then `w` | choose a window |
| `Ctrl+b` then `d` | detach; sessions keep running |
| `Ctrl+b` then `?` | show all current tmux bindings |
| `Enter` after a failed connection | close the pane displaying the error |
Change broadcast/solo keys with `multi.sync_key` and `multi.solo_key`;
`none` disables a binding. Existing user bindings take precedence and are
reported in the legend. Command alternatives are `netssh sync` and
`netssh sync --pane` (run locally inside the multiplexer).
Solo excludes a pane from broadcast; it does not toggle zoom.
### Multi-mode: zellij
Zellij's bottom status bar shows the keys for the current mode. These are
standard bindings; custom presets may differ.
| Key | Action |
|---|---|
| `Ctrl+t` then `s` | toggle broadcast for the entire tab |
| `Ctrl+p` then arrow key | move pane focus in pane mode |
| `Ctrl+p` then `f` | toggle fullscreen for the focused pane |
| `Ctrl+t` then left/right arrow | switch tabs in tab mode |
| `Enter` / `Esc` in a control mode | return to normal mode |
| `Ctrl+o` then `d` | detach; session keeps running |
| `Ctrl+g` | toggle locked mode to pass control keys to the remote application |
Zellij cannot exclude individual panes from broadcast. `netssh sync` toggles
the whole tab. When starting a new zellij session, enable broadcast manually
with `Ctrl+t` then `s`; `--sync` is applied automatically only inside an
existing zellij session.
## Recipes
**Everything through a bastion, except the bastion itself**
+37 -1
View File
@@ -18,6 +18,7 @@ type fake struct {
syncState string
keys map[string]string // existing prefix bindings by key
solo string
prefix string
n int
}
@@ -33,6 +34,8 @@ func (f *fake) Output(argv ...string) (string, error) {
f.calls = append(f.calls, strings.Join(argv, " "))
f.n++
switch argv[1] {
case "show-options":
return f.prefix, nil
case "new-window", "new-session":
return fmt.Sprintf("@%d %%%d", f.n, f.n), nil
case "split-window":
@@ -121,6 +124,8 @@ func TestTmuxInside(t *testing.T) {
"tmux list-keys -T prefix S",
"tmux list-keys -T prefix e",
"tmux source-file /tmp/l/netssh-multi.tmux.conf",
"tmux set-window-option -t @1 @netssh_keys keys: Ctrl+b then S: sync on/off | Ctrl+b then e: solo on/off",
"tmux set-window-option -t @1 pane-border-format #{@netssh_host}#{?pane_synchronized, [SYNC],#{?@netssh_solo, [SOLO],}} #{?pane_active, | #{@netssh_keys},} ",
"tmux select-window -t @1",
}
if strings.Join(f.calls, "\n") != strings.Join(want, "\n") {
@@ -234,7 +239,7 @@ func TestTmuxKeyBindings(t *testing.T) {
t.Errorf("conf lacks %q:\n%s", want, conf)
}
}
if hint != "keys: C-b S broadcast to all panes, C-b e exclude/include this pane" {
if hint != "keys: Ctrl+b then S: sync on/off | Ctrl+b then e: solo on/off" {
t.Errorf("hint %q", hint)
}
@@ -279,3 +284,34 @@ func TestToggleSyncPane(t *testing.T) {
t.Fatalf("zellij: %v", err)
}
}
func TestTmuxPersistentHints(t *testing.T) {
for _, tc := range []struct {
name string
keys map[string]string
want string
}{
{"custom prefix", nil, "keys: Ctrl+a then Ctrl+s: sync on/off | Ctrl+a then e: solo on/off"},
{"occupied key", map[string]string{"C-s": "bind-key -T prefix C-s display-time"}, "keys: Ctrl+a then e: solo on/off; C-a C-s kept your own binding (use netssh sync)"},
} {
t.Run(tc.name, func(t *testing.T) {
f := newFake(nil, "tmux")
f.prefix, f.keys = "C-a", tc.keys
if err := Open(Tmux, panes("a", "b"), Options{PerWindow: 1, SyncKey: "C-s", SoloKey: "e"}, f); err != nil {
t.Fatal(err)
}
n := 0
for _, call := range f.calls {
if strings.Contains(call, " @netssh_keys ") {
n++
if !strings.HasSuffix(call, " @netssh_keys "+tc.want) {
t.Fatalf("wrong persistent hint: %s", call)
}
}
}
if n != 2 {
t.Fatalf("hints installed in %d windows, want 2", n)
}
})
}
}
+23 -4
View File
@@ -27,6 +27,7 @@ func openTmux(panes []Pane, opts Options, r Runner) error {
}
groups := chunks(panes, opts.PerWindow)
first := ""
var windows []string
for i, group := range groups {
name := windowLabel(opts.Label, i, len(groups))
format := []string{"-P", "-F", "#{window_id} #{pane_id}", "-n", name}
@@ -52,6 +53,7 @@ func openTmux(panes []Pane, opts Options, r Runner) error {
}
}
window, pane, _ := strings.Cut(out, " ")
windows = append(windows, window)
if first == "" {
first = window
}
@@ -91,6 +93,17 @@ func openTmux(panes []Pane, opts Options, r Runner) error {
}
if keys != "" {
opts.Hint(keys)
// Window-local hints remain visible after attaching, including in an
// existing session. Keep other windows and the user's status bar intact.
for _, window := range windows {
if _, err := r.Output("tmux", "set-window-option", "-t", window, "@netssh_keys", keys); err != nil {
return err
}
if _, err := r.Output("tmux", "set-window-option", "-t", window, "pane-border-format",
" #{@netssh_host}#{?pane_synchronized, [SYNC],#{?@netssh_solo, [SOLO],}} #{?pane_active, | #{@netssh_keys},} "); err != nil {
return err
}
}
}
if inside {
_, err := r.Output("tmux", "select-window", "-t", first)
@@ -149,8 +162,8 @@ func bindKeys(r Runner, opts Options) (string, error) {
var conf strings.Builder
var hints, taken []string
for _, key := range []struct{ key, binding, what string }{
{opts.SyncKey, syncBinding, "broadcast to all panes"},
{opts.SoloKey, soloBinding, "exclude/include this pane"},
{opts.SyncKey, syncBinding, "sync on/off"},
{opts.SoloKey, soloBinding, "solo on/off"},
} {
if key.key == "" {
continue
@@ -161,7 +174,7 @@ func bindKeys(r Runner, opts Options) (string, error) {
continue
}
fmt.Fprintf(&conf, key.binding, key.key)
hints = append(hints, prefix+" "+key.key+" "+key.what)
hints = append(hints, displayKey(prefix)+" then "+displayKey(key.key)+": "+key.what)
}
if conf.Len() > 0 {
path := filepath.Join(opts.LayoutDir, "netssh-multi.tmux.conf")
@@ -172,7 +185,7 @@ func bindKeys(r Runner, opts Options) (string, error) {
return "", err
}
}
hint := "keys: " + strings.Join(hints, ", ")
hint := "keys: " + strings.Join(hints, " | ")
if len(hints) == 0 {
hint = "toggle broadcast with: netssh sync, netssh sync --pane"
}
@@ -192,3 +205,9 @@ func freeSession(r Runner, name string) string {
candidate = name + "-" + strconv.Itoa(n)
}
}
// displayKey expands tmux's modifier notation for the on-screen legend.
func displayKey(key string) string {
key = strings.ReplaceAll(key, "C-", "Ctrl+")
return strings.ReplaceAll(key, "M-", "Alt+")
}