# 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