当前位置:网站首页>Matrix of shell programming -- it's cute and cool
Matrix of shell programming -- it's cute and cool
2022-07-27 19:09:00 【Finger sword】
The code is as follows :
#!/bin/bash
blue="\033[0;34m"
brightblue="\033[1;34m"
cyan="\033[0;36m"
brightcyan="\033[1;36m"
green="\033[0;32m"
brightgreen="\033[1;32m"
red="\033[0;31m"
brightred="\033[1;31m"
white="\033[1;37m"
black="\033[0;30m"
grey="\033[0;37m"
darkgrey="\033[1;30m"
colors=($blue $brightgreen $grey)
spacing=${1:-100}
scroll=${2:-0}
screenlines=$(expr `tput lines` - 1 + $scroll)
screencols=$(expr `tput cols` / 2 - 1)
chars=(a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9 0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) ## Please modify the characters you want to display here
count=${#chars[@]}
colorcount=${#colors[@]}
trap "tput sgr0; clear; exit" SIGTERM SIGINT
if [[ $1 =~ "-h" ]]
then
echo "display a matrix screen in the terminal"
echo "usage: matrix [SPACING [SCROLL]]"
echo "example: matrix 100 0"
exit 0
fi
clear
tput cup 0 0
while :
do
for i in $(eval echo {1..$screenlines})
do
for i in $(eval echo {1..$screenlines})
do
rand=$(($RANDOM%$spacing))
case $rand in
0)
printf "${colors[$RANDOM%$colorcount]}${chars[$RANDOM%$count]} ";;
1)
printf " ";;
*)
printf "\033[2C";;
esac
done
printf "\n"
done
tput cup 0 0
doneThe implementation effect is as follows :
边栏推荐
猜你喜欢
随机推荐
Nacos集群部署-高可用保证
webservice的疑问
Power control
Blog Garden beautification tutorial
Unity学习笔记(刚体-物理-碰撞器-触发器)
Interceptor interceptor
Docker - docker installation, MySQL installation on docker, and project deployment on docker
Nacos基本概念和单机部署
ES6学习笔记(1)——快速入门
专项测试之「 性能测试」总结
收下这份实操案例,还怕不会用Jmeter接口测试工具
MongoDB
C # interaction with MySQL database - MySQL configuration and addition, deletion, query and modification operations
Unity display Kinect depth data
asp.net 的经验
微机原理学习笔记-通用整数指令及应用
The understanding of string in C.
PHP字符串操作
一篇让你掌握线程和线程池,还解决了线程安全问题,确定不看看?
Word 2007+ tips









