Setting session name in screen

It’s always annoying trying to remember what pid maps to a screen session, but it’s possible to actually name the session.

When starting a screen session, you can start it with arguments:

screen -S sessionname

Or within a current screen session, you can do:

C-a :
sessionname your_session_name

Now when you do a screen -ls, your sessions show up with meaningful names:

There are screens on:
        12117.irc      (Detached)
        9905.code      (Multi, detached)
        14850.projectx (Multi, attached)
3 Sockets in /var/run/screen/S-lindsay.

And connecting to them is as easy as:

screen -r projectx