plugfiles

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

starshell.sh (740B)


      1 #!/bin/bash
      2 # Nicholas Farrow 2019
      3 CFGLOC=~/.config
      4 SCENEDIR=$CFGLOC/starshell
      5 
      6 STARTSCENE=115
      7 
      8 # Make folder if doesn't exist
      9 [ -d $SCENEDIR ] || mkdir $SCENEDIR
     10 
     11 # If $STARTSCENE scene file does not exist, save starwars to file
     12 if [ ! -f $SCENEDIR/s_$STARTSCENE ]; then
     13     telnet towel.blinkenlights.nl | sed -e 's/.\[H/Z/g' | tee $SCENEDIR/main
     14 
     15     SCENEDATA=$(<"$SCENEDIR/main")
     16 
     17     # Load scenes
     18     IFS=$'Z' read -d '' -ra SCENES <<< "$SCENEDATA"
     19 
     20     echo ${#SCENES[@]}
     21 
     22     # Save "good" scenes to invividual files
     23     for SCENENUM in $(seq 115 ${#SCENES[@]}); do
     24          echo "${SCENES[$SCENENUM]}" >> $SCENEDIR/s_$SCENENUM
     25          echo $SCENENUM
     26     done
     27 fi
     28 
     29 # Print random scene
     30 echo "$(<$(ls "$SCENEDIR/s_"* | shuf -n 1))"