feat(multi): keep hotkeys visible and add README cheat sheet
This commit is contained in:
1 parent
c4466067a5
commit
c58b26ecf8
3 files changed
+159
-21
No files matched your search
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user