Run ‘screen’ and reconnect to the same session without arguments

This is just a little nugget I’ve had around for a while. I’m dusting it off and posting here more to test the WP-Syntax WordPress Plugin than any other reason.

I use screen, but I don’t leave myself logged in when I’m not at my computer. I can usually type ‘screen -R’ to reconnect to the same session the next day, but if I have more than one screen session running at once, I need to ‘screen -ls’, then figure out which one to reattach to. At least I think I need to do that… in addition to being to lazy to do all that, I’m too lazy to scour the man pages looking for the way to make it create or reattach to the same session every time.

If you call ‘screen’ with parameters, they will be used instead… This should allow you to use screen completely normally when necessary.

# Rename your screen binary to something else to get it out of
# the way, and save this script as 'screen' into the same
# directory. Make a note of what you called the original here:

# Make $DEFAULT_NAME whatever you want; you'll never actually see it:

if [ "$#" -eq 0 ]; then
    if [ "$SCREENLS" = "" ]; then
        $SCREEN -r "$DEFAULT_NAME"
    $SCREEN $@

Comments are closed.