Last active
July 30, 2020 03:52
-
-
Save gabochi/28e33e07faae7323652ed2f4797d79bc to your computer and use it in GitHub Desktop.
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 | |
# init time | |
t=0 | |
# width (cols) | |
w=64 | |
# sleep time after each line | |
s=0.05 | |
# default expression | |
expression='b=$(( t>>6^t%64 ))' | |
edit_expression(){ | |
printf "\033[48;5;0m\ntype another expression ('q' anywhere will exit):\n" | |
read -e -i "${expression}" expression | |
[[ "${expression}" == *"q"* ]] && exit | |
} | |
# interrupt calls function | |
trap 'edit_expression' INT | |
# main loop . . . | |
while true | |
do | |
t=$((t+1)) | |
eval ${expression} | |
b=$((b%256)) | |
printf "\033[48;5;${b}m " | |
[ $((t%w)) -eq 0 ] && printf "\n" && [ "${s}" != "0" ] && sleep ${s} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment