Created
October 6, 2014 16:00
-
-
Save marc-hanheide/c805787b36702b6779c1 to your computer and use it in GitHub Desktop.
automatically start tmux in interactive ssh sessions (to be used in .bashrc)
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
case $- in | |
*i*) # interactive shell | |
if [ -z "$TMUX" ]; then | |
if [ "$SSH_CLIENT" ]; then | |
TMUX_SESSION=`echo ${SSH_CLIENT} | cut -f1 -d" "` | |
echo "checking for tmux session with ID $TMUX_SESSION" | |
if tmux has-session -t "$TMUX_SESSION" > /dev/null; then | |
exec tmux at -t "$TMUX_SESSION" | |
else | |
exec tmux new-session -s "$TMUX_SESSION" | |
fi | |
fi | |
fi | |
;; | |
*) # non-interactive shell | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment