Return to Snippet

Revision: 29933
at August 5, 2010 06:42 by wesalvaro


Initial Code
if [[ "$STY" == "" ]]; then
  screen -r > .screenResult
  if [[ $? == 1 ]]; then
    export whoami=`whoami`
    export total=`cat .screenResult | grep -i "attached" | wc -l`
    export s=$[`cat .screenResult | grep "${whoami}-AS" | grep -iv "attached" | wc -l`]
    if [[ $s == 0 ]] ; then
      echo 'Starting new screen session as no unattached screen exist'
      screen -S ${whoami}-AS
    else
      export screenSessionCount=$[$s-1]
      echo 'Resuming the first of ' $screenSessionCount  'screen sessions'
      export r=`screen -r | tail -n $s | head -n 1 | awk -F. '{printf "%d\n", $1}'`
      screen -r $r
    fi
  else
    echo 'Resumed single screen'
  fi
else
  echo "You are on screen $WINDOW! "
fi

Initial URL

                                

Initial Description

                                

Initial Title
Activate Screen Session Automatically

Initial Tags

                                

Initial Language
Bash