ChristBASHTree/tree-ES.sh

71 lines
1.4 KiB
Bash
Raw Normal View History

2014-12-24 15:38:57 +00:00
#!/bin/bash
trap "tput reset; tput cnorm; exit" 2
clear
tput civis
lin=2
col=$(($(tput cols) / 2))
c=$((col-1))
est=$((c-2))
color=0
tput setaf 2; tput bold
2018-01-12 21:00:25 +00:00
# Tree
2014-12-24 15:38:57 +00:00
for ((i=1; i<20; i+=2))
{
tput cup $lin $col
for ((j=1; j<=i; j++))
{
echo -n \*
}
let lin++
let col--
}
tput sgr0; tput setaf 3
2018-01-12 21:00:25 +00:00
# Trunk
2014-12-24 15:38:57 +00:00
for ((i=1; i<=2; i++))
{
tput cup $((lin++)) $c
echo 'mWm'
}
2018-01-12 21:00:25 +00:00
new_year=$(date +'%Y')
let new_year++
2014-12-24 15:38:57 +00:00
tput setaf 1; tput bold
tput cup $lin $((c - 6)); echo FELICES FIESTAS
2018-01-12 21:00:25 +00:00
tput cup $((lin + 1)) $((c - 9)); echo Y mucho CODIGO en $new_year
2014-12-24 15:38:57 +00:00
let c++
k=1
2018-01-12 21:00:25 +00:00
# Lights and decorations
2014-12-24 15:38:57 +00:00
while true; do
for ((i=1; i<=35; i++)) {
2018-01-12 21:00:25 +00:00
# Turn off the lights
2014-12-24 15:38:57 +00:00
[ $k -gt 1 ] && {
tput setaf 2; tput bold
2018-01-12 21:00:25 +00:00
tput cup ${line[$[k-1]$i]} ${column[$[k-1]$i]}; echo \*
unset line[$[k-1]$i]; unset column[$[k-1]$i] # Array cleanup
2014-12-24 15:38:57 +00:00
}
li=$((RANDOM % 9 + 3))
2018-01-12 21:00:25 +00:00
start=$((c-li+2))
co=$((RANDOM % (li-2) * 2 + 1 + start))
tput setaf $color; tput bold # Switch colors
2014-12-24 15:38:57 +00:00
tput cup $li $co
echo o
2018-01-12 21:00:25 +00:00
line[$k$i]=$li
column[$k$i]=$co
2014-12-24 15:38:57 +00:00
color=$(((color+1)%8))
2018-01-12 21:00:25 +00:00
# Flashing text
2014-12-24 15:38:57 +00:00
sh=1
for l in C O D I G O
do
tput cup $((lin+1)) $((c-3+sh))
echo $l
let sh++
sleep 0.01
done
}
k=$((k % 2 + 1))
done