Deprecated Behaviour

The inane, sometimes insane, ramblings from the mind of Brenton Alker.

Automatically Start Screen

I often find myself only a few minutes (or hours) into a session at the bash CLI/prompt before starting a process that takes some time to complete, such as a long SQL query, or a file download.

Being impatient as I am, I quickly reach for the trusty ‘Ctrl-A c’ key sequence to start a new Screen window, only to realise I never started screen in the first place (arg…)

To prevent such annoyance, I have added this handy snippet to my ~/.bashrc:

if [ "$STY" = "" ]; then
        exec screen -RR

Which automatically starts screen when you log into bash, by opening a new terminal for example. Other examples I have seen, such as on the Screen Users Mailing List use screen’s “-dR” or “-x” flags when starting screen to ensure they only have one screen open, but as I am still partial to having multiple terminals running, I currently prefer this option.