1 2 3
if [[ -n "$PS1" ]] && [[ -z "$TMUX" ]] && [[ -n "$SSH_CONNECTION" ]]; then tmux attach-session -t ssh_tmux || tmux new-session -s ssh_tmux fi