DEV Community

Discussion on: Persistent SSH Sessions with Tmux

sndp487 profile image

I was getting sessions should be nested with care, unset $TMUX to force at the top of tmux when using tmux attach || tmux new. What happens is tmux also executes .bashrc/profile.

So now I use this:

if [[ ! "$TERM" =~ "screen" ]]; then
tmux attach -t default || tmux new -s default

in my .bashrc

TERM is set to 'screen' in tmux environment.