Last active
December 31, 2016 22:21
-
-
Save insanity54/83550daec75f4ceb0482d78c668b5c87 to your computer and use it in GitHub Desktop.
Fortune generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Have a character tell you a fortune every n minutes | |
| # Dependencies: | |
| # - sed | |
| # - shuf | |
| # - sleep | |
| # - fortune | |
| # - cowsay | |
| # configure how often the fortune should change (in seconds) | |
| # prefer to use the command line argument, if there is one. | |
| if [ -z $1 ]; then | |
| interval=$((60*80)) # default to 80 minutes | |
| else | |
| interval=$1 | |
| fi | |
| echo "displaying a new fortune every ${interval} seconds." | |
| sleep 5 | |
| # every n minutes, display a new fortune | |
| while ((1)) | |
| do | |
| clear | |
| # choose a random character from those available on the system | |
| character=$(cowsay -l | sed '1d' | sed 's/ /\n/g' | shuf | sed -n '1p') | |
| cowsay -f ${character} $(fortune) | |
| sleep ${interval} | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment