From e65c3331b43c10ec798b233602f4212696a23316 Mon Sep 17 00:00:00 2001 From: daniel fusser Date: Wed, 8 Jul 2026 22:23:02 +0200 Subject: [PATCH] switch tmux to individual sessions --- mksh/mkshrc | 8 +++++--- tmux/tmux.conf | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/mksh/mkshrc b/mksh/mkshrc index 63df11f..cc4967b 100644 --- a/mksh/mkshrc +++ b/mksh/mkshrc @@ -216,10 +216,12 @@ PS4='[$EPOCHREALTIME] '; PS1='#'; (( USER_ID )) && PS1='→'; PS1=$'\001\r''${| \\builtin return $e } '"${hostcol}${bld}$PS1 ${rst}" -# tmux auto-attach: one shared session per host. No -exec, so if tmux is -# missing or exits/crashes for any reason, this shell just continues normally. +# tmux auto-attach: bare invocation so tmux.conf's default-client-command +# grants each connection its own session grouped with "main" (shared panes, +# independent window navigation). No -exec, so if tmux is missing or +# exits/crashes for any reason, this shell just continues normally. tmuxbin=$(\\builtin whence -p tmux 2>/dev/null) if [[ $- = *i* ]] && [[ -t 0 ]] && [[ -z $TMUX ]] && [[ -n $tmuxbin ]]; then - "$tmuxbin" new-session -A -s "${HOSTNAME:-main}" + "$tmuxbin" fi unset tmuxbin diff --git a/tmux/tmux.conf b/tmux/tmux.conf index d0e25dc..3f1a75b 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -4,6 +4,12 @@ set-option -g focus-events on set -s escape-time 0 set -g detach-on-destroy off set -g destroy-unattached off + +# bare `tmux` (no subcommand, e.g. from mkshrc's auto-attach) gets its own +# session grouped with "main" - shared panes/windows, independent per-client +# current-window navigation. Self-cleans on detach via destroy-unattached. +new-session -d -s main +set -g default-client-command "new-session -t main ; set-option destroy-unattached on" # set -g default-terminal "screen-256color" set -g default-terminal "tmux-256color" set -g history-limit 50000