Last active
December 21, 2015 11:19
-
-
Save TheTechmage/6298223 to your computer and use it in GitHub Desktop.
On login/connection, join an existing tmux session. If none exists, create one. If creating a session fails, drop back to the user's shell. Otherwise, if there weren't any errors, disconnect the user.
This file contains 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
# Automatically connect to (or establish) a tmux session | |
## if we are in a TTY and we aren't in a tmux session and we aren't connected through a gui... | |
if ( [ -t 1 ] && ! [ -n "$TMUX" ] && [ -z "$DISPLAY" ] ); then | |
## Attach to tmux, if we fail, start tmux. | |
## On success, exit the ssh connection. | |
## On failure, give the user a warning and drop them to the shell | |
tmux a || tmux | |
if [ $? -eq 0 ]; then | |
exit | |
else | |
echo "Warning: Unable to connect to tmux, falling back to the normal prompt" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment