Skip to content

Instantly share code, notes, and snippets.

@matutter
Last active March 30, 2017 12:43
Show Gist options
  • Select an option

  • Save matutter/565f91f7c46d074a63fab931833d1cf9 to your computer and use it in GitHub Desktop.

Select an option

Save matutter/565f91f7c46d074a63fab931833d1cf9 to your computer and use it in GitHub Desktop.
Automatically connect to tmux session
##
# Check for TMUX session, create or attach "remote" session if connected through
# ssh or create or attach "local" session if connected through other means
HOST_SESSION_NAME="local"
SSH_SESSION_NAME="remote"
SESSION_NAME=$HOST_SESSION_NAME
if [ ! -n "$TMUX" ]; then
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
SESSION_NAME=$SSH_SESSION_NAME
fi
countDown "TMUX connecting to $SESSION_NAME session" 3
tmux attach-session -t $SESSION_NAME || tmux new-session -s $SESSION_NAME
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment