Skip to content

Instantly share code, notes, and snippets.

@dahse89
Forked from sontek/snowjob.sh
Created November 16, 2018 22:22
Show Gist options
  • Save dahse89/4772a19fb94c474bd4f7e9a5ca4bd1c9 to your computer and use it in GitHub Desktop.
Save dahse89/4772a19fb94c474bd4f7e9a5ca4bd1c9 to your computer and use it in GitHub Desktop.
Make your terminal snow
#!/bin/bash
LINES=$(tput lines)
COLUMNS=$(tput cols)
declare -A snowflakes
declare -A lastflakes
clear
function move_flake() {
i="$1"
if [ "${snowflakes[$i]}" = "" ] || [ "${snowflakes[$i]}" = "$LINES" ]; then
snowflakes[$i]=0
else
if [ "${lastflakes[$i]}" != "" ]; then
printf "\033[%s;%sH \033[1;1H " ${lastflakes[$i]} $i
fi
fi
printf "\033[%s;%sH\u274$[($RANDOM%6)+3]\033[1;1H" ${snowflakes[$i]} $i
lastflakes[$i]=${snowflakes[$i]}
snowflakes[$i]=$((${snowflakes[$i]}+1))
}
while :
do
i=$(($RANDOM % $COLUMNS))
move_flake $i
for x in "${!lastflakes[@]}"
do
move_flake "$x"
done
sleep 0.1
done
@dahse89
Copy link
Author

dahse89 commented Nov 16, 2018

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