Skip to content

Instantly share code, notes, and snippets.

@razielgn
Created March 16, 2017 19:29
Show Gist options
  • Save razielgn/f331ac702f3c7714707b5e83f83f3cc4 to your computer and use it in GitHub Desktop.
Save razielgn/f331ac702f3c7714707b5e83f83f3cc4 to your computer and use it in GitHub Desktop.
Automatically start tmux on ssh connection. Logout on detach.
# Original: http://blog.thelinuxkid.com/2013/06/automatically-start-tmux-on-ssh.html
# Saving for our children.
# This should always be run last either in .bashrc or as a script in .bashrc.d
if [[ -z "$TMUX" ]]; then
tmux has-session &> /dev/null
if [ $? -eq 1 ]; then
exec tmux new
exit
else
exec tmux attach
exit
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment