Created
March 3, 2016 19:35
-
-
Save mhartington/018fcd9df98253a28841 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ### Customization: | |
| 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" | |
| # Choose the colors that will be used from the above list | |
| # space-separated list | |
| # e.g. `colors=($green $brightgreen $darkgrey $white)` | |
| colors=($green $brightgreen) | |
| ### End customization | |
| ### Do not edit below this line | |
| spacing=${1:-100} # the likelihood of a character being left in place | |
| scroll=${2:-0} # 0 for static, positive integer determines scroll speed | |
| 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 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 0 1 2 3 4 5 6 7 8 9 ^) | |
| # charset via Carl: | |
| chars=(ï½± ï½² ï½³ ï½´ ï½µ ï½¶ ï½· ク ï½¹ コ ï½» ï½¼ ï½½ ï½¾ ソ ï¾€ ï¾x129 ツ テ ト ï¾… ニ ヌ ネ ノ ハ ヒ フ ï¾x141 ホ ï¾x143 ï¾x144 ム ï¾’ モ ï¾” ユ ï¾– ï¾— リ ï¾™ レ ï¾› ワ ï¾x157) | |
| count=${#chars[@]} | |
| colorcount=${#colors[@]} | |
| trap "tput sgr0; clear; exit" SIGTERM SIGINT | |
| if [[ $1 =~ '-h' ]]; then | |
| echo "Display a Matrix(ish) 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..$screencols}) | |
| do rand=$(($RANDOM%$spacing)) | |
| case $rand in | |
| 0) | |
| printf "${colors[$RANDOM%$colorcount]}${chars[$RANDOM%$count]} " | |
| ;; | |
| 1) | |
| printf " " | |
| ;; | |
| *) | |
| printf "\033[2C" | |
| ;; | |
| esac | |
| done | |
| printf "\n" | |
| # sleep .005 | |
| done | |
| tput cup 0 0 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment