tmux: check if session is interactive

This commit is contained in:
Michael Grote 2024-09-13 19:01:33 +02:00
parent 4900f4aaa4
commit 561a0647be

View file

@ -12,12 +12,15 @@ source "${HOME}/dotfiles/.bash_ps1"
# add my scripts to PATH # add my scripts to PATH
PATH=$PATH:"${HOME}/dotfiles/scripts" PATH=$PATH:"${HOME}/dotfiles/scripts"
### tmux auto attach ## check interactive shell https://unix.stackexchange.com/questions/26676/how-to-check-if-a-shell-is-login-interactive-batch
# Check if the user ID is not 0 (root) if [[ $- == *i* ]] ; then
if [ "$EUID" -ne 0 ]; then ### tmux auto attach
# then auto attach # Check if the user ID is not 0 (root)
if command -v tmux &> /dev/null && [ -z "$TMUX" ]; then if [ "$EUID" -ne 0 ]; then
tmux attach -t default || tmux new -s default # then auto attach
if command -v tmux &> /dev/null && [ -z "$TMUX" ]; then
tmux attach -t default || tmux new -s default
fi
fi fi
fi fi