You can use this in your shell dotfile (e.g. ’/.bash_profile’, ’/.zshrc’) to create a ‘screen’ session when you log in or reattach to an existing screen:
1 2 3 if [[ $TERM != 'screen' ]] ; then 4 if [[ `screen -list | grep -v "No" | awk '$2 { print }' | wc -l` == 0 ]] ; then 5 screen 6 else 7 screen -dr 8 fi 9 fi 10