shell 指令的圣诞树(情侣圣诞节)

2023-12-23 18:02:53
#!/bin/bash
#用shell编写一个圣诞树
#创建时间2021-12-21
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

# 打印树叶
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

# 打印树干
for ((i=1; i<=2; i++))
{
    tput cup $((lin++)) $c
    echo '|||'
}
new_year=$(date +'%Y')
let new_year++
tput setaf 222; tput bold
tput cup $lin $((c - 10));  echo $new_year  圣诞节快乐!!!
color=122
tput setaf $color; tput bold
tput cup $((lin + 1)) $((c - 10)); echo 我爱你幺幺
let c++
k=1
                                                                      
while true; do
    for ((i=1; i<=35; i++)) {
        # Turn off the lights
        [ $k -gt 1 ] && { 
            tput setaf 2; tput bold
            tput cup ${line[$[k-1]$i]} ${column[$[k-1]$i]}; echo \*
            unset line[$[k-1]$i]; unset column[$[k-1]$i] 
        }

        li=$((RANDOM % 9 + 3))
        start=$((c-li+2))
        co=$((RANDOM % (li-2) * 2 + 1 + start))
        tput setaf $color; tput bold
        tput cup $li $co
        echo o
        line[$k$i]=$li
        column[$k$i]=$co
        color=$(((color+1)%8))

        sh=1
        #for l in M O N E Y
        for l in 永远爱你
        do  
            tput cup $((lin+1)) $((c+sh))
            echo $l
            let sh++
            let sh++
            sleep 0.5
        done
    }
    k=$((k % 2 + 1))
done

文章来源:https://blog.csdn.net/weixin_64965464/article/details/135168796
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。