this one is rather complicated to explain and I failed in imagining a short description of this to be able to search for.
My current setting is that when I open a terminal, due to this line
if [[ -n "$PS1" ]] && [[ -z "$TMUX" ]]
then
tmux && exit
fi
tmux is started instantly. And since I've got an && exit
after the tmux
command the the tmux encapsulating shell is closed instantly when exiting tmux.
I think this is a nice behaviour by default, but in rare occasions I want to detach or exit tmux without exiting the encapsulating shell.
I thought I'd can do this by entering exit 1
inside tmux so that the exit code of tmux is !=0
and thus the exit
of the encapsulating shell isn't executed, but it seems that tmux is exiting with exit code 0 despite the exit 1
inside.
Can anyone imagine a way to realize my aim to exit the encapsulating bash by default but being able to manually change this?
tmux ; [ -e ~/DoNotExit ] || exit
and then create the file if you don't want to exit? Expand the idea to imclude a PID if you have multiple parallel sessions, maybe throw in an automatic rm of the file?