Benjamin W. Smith

Benjamin W. Smith

Benjamin W. Smith  //  Sysadmin by trade, Pythonista by passion. Dad to two boys and a girl. Guitarist. I like my coffee black, just like my metal.

Aug 9 / 7:10pm

PROTIP: Don't leave screen sessions laying around idly.

I constantly forget that I already have screen sessions available when I log in on Monday mornings. I don’t like that because it’s wasteful, but I’m just lazy enough that the thought alone isn’t enough to make me do something about it until now. So, to combat this, I whipped the script below as a reminder to use one of them, or get rid of them.

This will only fire when you are not already in a screen session, courtesy of the $WINDOW environment variable.

Add this to your ~/.bashrc

function list_screens() {
    if ! test $WINDOW;
    then
        echo
        echo "Current screen sessions available"
        screen -ls
    fi
}

list_screens

Yay! Now I can continue to be lazy!

You can find this and other junk over in my dotfiles at bitbucket: https://bitbucket.org/benjaminws/dotfiles/

Filed under  //  bash   linux   protip