fix(tmux): bind nested prefix before unbind so an empty table cannot abort the chain

A user tmux config that leaves the prefix table empty makes
unbind-key -a -T prefix fail and drop later commands in the \; chain,
including send-prefix and remain-on-exit failed. Bind C-q send-prefix,
clear the table, then bind it again.

Also accept macOS ttys in the TUI switch-guard test without reading
/proc, and describe the client_pid hook escape as defensive on tmux 3.4.

Co-authored-by: DDT <1786035110@qq.com>
This commit is contained in:
DDTandDDT committed 2026-10-23 09:08:48 +00:00
1 parent daeea54495
commit 9fc2773176
10 files changed
+106 -28

No files matched your search

+6 -2
View File
@@ -95,7 +95,8 @@ ssh -o BatchMode=yes -t <connection-args> user@host \
set -t codeman-ssh-<id8> status off \; set -t codeman-ssh-<id8> mouse off \; \
set -t codeman-ssh-<id8> prefix C-q \; set -s escape-time 0 \; \
set -t codeman-ssh-<id8> window-size latest \; \
unbind-key -a -T prefix \; bind-key -T prefix C-q send-prefix'
bind-key -T prefix C-q send-prefix \; unbind-key -a -T prefix \; \
bind-key -T prefix C-q send-prefix'
```
Key points:
@@ -111,7 +112,10 @@ Key points:
uses. Options are set per-session (`set -t`), never `-g`, so a shared remote
tmux server's other sessions are untouched (#145 hardening). The prefix
*table* is server-global, so the create chain reduces it to `C-q send-prefix`
(`unbind-key -a -T prefix` then `bind-key`). Otherwise Ctrl+Q then `)` moves
(bind `send-prefix`, then `unbind-key -a -T prefix`, then bind it again). The
leading bind keeps an empty prefix table from aborting the chain:
`unbind-key -a` fails with "table prefix doesn't exist" and tmux drops every
later command, including `remain-on-exit failed`. Without that reduction, Ctrl+Q then `)` moves
the inner client onto a sibling session. A non-owned attach does not do this:
it joins the remote Codeman's own socket. Note the
asymmetry: **discovery/attach (COD-105) target the canonical `-L codeman`