Skip to content

Instantly share code, notes, and snippets.

@ch604
Forked from sontek/snowjob.sh
Last active December 31, 2015 22:49

Revisions

  1. ch604 revised this gist Dec 20, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions snowjob.sh
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ declare -A lastflakes

    clear

    function move_flake() {
    move_flake() {
    i="$1"

    if [ "${snowflakes[$i]}" = "" ] || [ "${snowflakes[$i]}" = "$LINES" ]; then
    @@ -19,7 +19,7 @@ function move_flake() {
    fi
    fi

    printf "\033[%s;%sH*\033[1;1H" ${snowflakes[$i]} $i
    printf "\033[%s;%sH\u274"$[($RANDOM%6)+3]"\033[1;1H" ${snowflakes[$i]} $i

    lastflakes[$i]=${snowflakes[$i]}
    snowflakes[$i]=$((${snowflakes[$i]}+1))
  2. @sontek sontek renamed this gist Dec 23, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. @sontek sontek revised this gist Dec 21, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -15,11 +15,11 @@ function move_flake() {
    snowflakes[$i]=0
    else
    if [ "${lastflakes[$i]}" != "" ]; then
    printf "\033[%s;%sH \033[0;0H " ${lastflakes[$i]} $i
    printf "\033[%s;%sH \033[1;1H " ${lastflakes[$i]} $i
    fi
    fi

    printf "\033[%s;%sH*\033[0;0H" ${snowflakes[$i]} $i
    printf "\033[%s;%sH*\033[1;1H" ${snowflakes[$i]} $i

    lastflakes[$i]=${snowflakes[$i]}
    snowflakes[$i]=$((${snowflakes[$i]}+1))
  4. @sontek sontek revised this gist Dec 21, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -3,11 +3,11 @@
    LINES=$(tput lines)
    COLUMNS=$(tput cols)

    clear

    declare -A snowflakes
    declare -A lastflakes

    clear

    function move_flake() {
    i="$1"

  5. @sontek sontek created this gist Dec 21, 2011.
    40 changes: 40 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    #!/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