Skip to content

Instantly share code, notes, and snippets.

@kristopolous
Last active October 31, 2022 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristopolous/a7c710ef484c960c110f684d8cf48a13 to your computer and use it in GitHub Desktop.
Save kristopolous/a7c710ef484c960c110f684d8cf48a13 to your computer and use it in GitHub Desktop.
Animal-say fortune, like cowsay but more animals and faster
#!/bin/bash
cat << ENDL
- - - ~ ~~~~==~#=###=#~==~~~~~ ~ - - -
$(fortune | sed -E 's/^\s+//g' | fold -sbw 40 | sed -E 's/^/ /')
- - - ~ ~~~~==~#=###=#~==~~~~~ ~ - - -
$(curl -s https://9ol.es/animals.db | shuf -n 1 | tr 'F' '\n' | gawk ' { if (FNR == 1) { printf " \\ ";} else if (FNR == 2) { printf " \\ "; } else { printf " " }; print $0 } ';)
ENDL
@kristopolous
Copy link
Author

see it in action at the hn/hn account here: https://bootstra386.com/WELCOME.HTM

@kristopolous
Copy link
Author

kristopolous commented Oct 31, 2022

I optimized the db with the following

{ for i in $(seq 1 $(cat animals.db | wc -l )); do 
head -$i animals.db | tail -1 | tr 'F' '\n' | gawk ' { if (FNR == 1) { printf "     \\  ";} else if (FNR == 2) { printf "      \\ "; } else { printf "        " }; print $0 } ' | tr '\n' 'F'; 
echo ""; done } > animals-optimized.db

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment