mksh: auto-attach a shared tmux session per host on login
Guarded to only fire for interactive shells with a real tty, when tmux isn't already active, and only if the tmux binary is found - so it falls back to a plain shell if any of that isn't true. Not exec'd, so an unexpected tmux exit also drops back to a normal shell instead of closing the connection. Replaces manually running bin/tmx. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -215,3 +215,11 @@ PS4='[$EPOCHREALTIME] '; PS1='#'; (( USER_ID )) && PS1='→'; PS1=$'\001\r''${|
|
|||||||
|
|
||||||
\\builtin return $e
|
\\builtin return $e
|
||||||
} '"${hostcol}${bld}$PS1 ${rst}"
|
} '"${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
|
||||||
|
|||||||
Reference in New Issue
Block a user