Skip to content

Instantly share code, notes, and snippets.

@jeekl
Last active December 26, 2015 21:38
Show Gist options
  • Save jeekl/7216949 to your computer and use it in GitHub Desktop.
Save jeekl/7216949 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Checks if a tmux session with name $host exists, on remote $host.
# if so connect to it otherwise create session and connect to it.
host=$1
ssh $USER@$host tmux has-session -t $host 2>/dev/null
if [ "$?" -eq 1 ] ; then
ssh $USER@$host tmux new-session -d -s $host
fi
ssh -t $USER@$host tmux attach-session -t $host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment