Whenever I log into a remote Linux based machine via SSH, I first start a GNU screen session. Any when I forget, I often regret it when I close the session window, as this also terminates the processes I usually want to continue in the background.

To not be able to forget this, I added

# for SSH sessions which are not already in gnu screen -> attach to a detached one or create a new session
if [[ ! -z "${SSH_CLIENT}" && -z "${STY}" ]]; then screen -RR; fi

at the end of ~/.bashrc to automatically reconnect to a previous screen session, or connect to a new screen session if no detached one is available. It does that only for SSH logins and only if the shell is not already inside a screen session (this avoids recursive loops).