The Matrix in your terminal

chriswelborn 0 Tallied Votes 1K Views Share

I didn't write this, the credits are in the code. It's a code-golf version, and I'm sorry about that. I am trying to 'decode' it but I don't have the skills, so the 'decoded' version doesn't have the right colors.

This is an example of what you can do with BASH, or possibly other shells, and it's just a neat thing to see. So I offer this up for your amusement, I've tested it and combed through it to make sure there's no hidden tricks. As far as I can tell it only uses a few commands like echo, printf, sleep, and eval, with if statements and color codes.

The Matrix (matrix.sh):

#!/bin/bash
echo -e "\033[2J\033[?25l"; R=`tput lines` C=`tput cols`;: $[R--] ; while true 
do ( e=echo\ -e s=sleep j=$[RANDOM%C] d=$[RANDOM%R];for i in `eval $e {1..$R}`;
do c=`printf '\\\\0%o' $[RANDOM%57+33]` ### http://bruxy.regnet.cz/web/linux ###
$e "\033[$[i-1];${j}H\033[32m$c\033[$i;${j}H\033[37m"$c; $s 0.1;if [ $i -ge $d ]
then $e "\033[$[i-d];${j}H ";fi;done;for i in `eval $e {$[i-d]..$R}`; #[mat!rix]
do echo -e "\033[$i;${j}f ";$s 0.1;done)& sleep 0.05;done #(c) 2011 -- [ BruXy ]