fix tmux auto-attach spawning nested clients and blocking detach
Two problems made the auto-attach loop: $TMUX was the only nesting guard, and it is trivially lost - sudo -i, env -i, ssh, and dropbear all hand back an interactive tty shell with it unset, so a shell below tmux would start another tmux. The guard also never checked for a login shell, so anything spawning `$SHELL -i` (fzf-tmux, file-manager shell escapes, editor :sh) dragged in a whole tmux client and a fresh grouped session. Now guarded on a login shell with stdin and stdout both a terminal, a $TERM that can host tmux, and an exported $TMUX_AUTOSTART that survives into panes and into nested shells that strip $TMUX. detach-on-destroy was off while the per-client sessions set destroy-unattached on. Those fight: detaching destroys the session, and off means the client is then switched to the most recently active remaining session instead of being allowed to leave - so detach put you back into "main". Restored to on, which is also the default. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
0a4166189f
commit
67e6d4ba4d
+4
-1
@@ -2,7 +2,10 @@
|
||||
# set-option -g default-shell /bin/mksh
|
||||
set-option -g focus-events on
|
||||
set -s escape-time 0
|
||||
set -g detach-on-destroy off
|
||||
# Must stay `on` (the default): the per-client sessions below set
|
||||
# destroy-unattached, so with `off` a detach would destroy the session and then
|
||||
# punt the client into "main" instead of letting it leave.
|
||||
set -g detach-on-destroy on
|
||||
set -g destroy-unattached off
|
||||
|
||||
# bare `tmux` (no subcommand, e.g. from mkshrc's auto-attach) gets its own
|
||||
|
||||
Reference in New Issue
Block a user