Last active
October 31, 2022 05:05
-
-
Save kristopolous/a7c710ef484c960c110f684d8cf48a13 to your computer and use it in GitHub Desktop.
Animal-say fortune, like cowsay but more animals and faster
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 | |
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 |
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
see it in action at the hn/hn account here: https://bootstra386.com/WELCOME.HTM