# tmux Start Script Need To Work!!
if which tmux >/dev/null 2>&1; then
#if not inside a tmux session, and if no session is started, start a new session
test -z "$TMUX" && (tmux attach || tmux new-session)
fi
Arch wiki 网站上很好: https://wiki.archlinux.org/index.php/Tmux 现在和以前不同了
答案1
Screen 没有环境变量,TMUX
但TERM
设置为“screen”,因此您可以检查它。 Screen 有一种在一个标志集中重新附加/创建所有内容的方法。
-d -R Reattach a session and if necessary detach or even create it first.
# screen Start Script Need To Work!!
if which screen >/dev/null 2>&1; then
#if not inside a screen session, and if no session is started, start a new session
[ "$TERM" != "screen" ] && screen -d -R
fi