With the terminal: Make snow fall on your console

Interesting and entertaining Script that i found in ParadiseLinux which makes snowflakes fall indefinitely on our console.

The code in question is this:

[Code]

#! / 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❄ \ 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

[/ Code]

We save it in a file and give it any name, let's say snowing.sh. Then we give it execution permissions:

$ chmod +x nevando.sh

and we execute it in a terminal

$ ./nevando.sh

All that remains is to put some Christmas song in the background 😛


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Courage said

    A little late is this, but hey

    1.    Carlos-Xfce said

      A little late for those from the northern hemisphere, but also, a little early for those from the southern hemisphere.