Skip to content

Instantly share code, notes, and snippets.

@wolph
Created June 19, 2012 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wolph/2955187 to your computer and use it in GitHub Desktop.
Save wolph/2955187 to your computer and use it in GitHub Desktop.
Screen reattach script for bash/zsh/etc..
# If we're not in screen, resume the existing session
if [[ "$TERM" != screen* ]]; then
# Clean up old sessions
screen -wipe > /dev/null
# See if there are sessions available
screen -q -ls
if [[ "$?" -ge "10" ]]; then
# Reconnect if there are
exec screen -x
else
# Create a new session if not
exec screen
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment