Skip to content

Instantly share code, notes, and snippets.

@Marak
Forked from sontek/snowjob.sh
Created December 21, 2011 10:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marak/1505534 to your computer and use it in GitHub Desktop.
Save Marak/1505534 to your computer and use it in GitHub Desktop.
Make your terminal snow
#!/bin/bash
LINES=$(tput lines)
COLUMNS=$(tput cols)
clear
declare -A snowflakes
declare -A lastflakes
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[0;0H " ${lastflakes[$i]} $i
fi
fi
printf "\033[%s;%sH*\033[0;0H" ${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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment