Skip to content

Instantly share code, notes, and snippets.

@qub1750ul
Last active January 25, 2018 18:36
Show Gist options
  • Save qub1750ul/5e2eb6262e0f86e538aa87ff653560ff to your computer and use it in GitHub Desktop.
Save qub1750ul/5e2eb6262e0f86e538aa87ff653560ff to your computer and use it in GitHub Desktop.
Let It Snow In Your Terminal
#!/bin/bash
# Single cases are from
# http://climagic.org/coolstuff/let-it-snow.html
#
# Multi-mode script
# made by qub1750ul
fallSpeed=0.1
COLUMNS=$( tput cols )
LINES=$( tput lines )
case "$1" in
""|0)
# Unicode snowflake version
clear ;
while :;
do
echo $LINES $COLUMNS $(($RANDOM%$COLUMNS)) $(printf "\u2744\n") ;
sleep $fallSpeed ;
done | \
gawk '{a[$3]=0;for(x in a) {o=a[x];a[x]=a[x]+1;printf "\033[%s;%sH ",o,x;printf "\033[%s;%sH%s \033[0;0H",a[x],x,$4;}}'
;;
1)
# Short version
for((I=0;J=--I;)) do
clear ;
for((D=$LINES;S=++J**3%$COLUMNS,--D;)) do
printf %*s.\\n $S ;
done;
sleep $fallSpeed ;
done
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment