Created
March 16, 2017 19:29
-
-
Save razielgn/f331ac702f3c7714707b5e83f83f3cc4 to your computer and use it in GitHub Desktop.
Automatically start tmux on ssh connection. Logout on detach.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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