diff --git a/mksh/mkshrc b/mksh/mkshrc index 87859a7..63df11f 100644 --- a/mksh/mkshrc +++ b/mksh/mkshrc @@ -215,3 +215,11 @@ 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. +tmuxbin=$(\\builtin whence -p tmux 2>/dev/null) +if [[ $- = *i* ]] && [[ -t 0 ]] && [[ -z $TMUX ]] && [[ -n $tmuxbin ]]; then + "$tmuxbin" new-session -A -s "${HOSTNAME:-main}" +fi +unset tmuxbin