Some Fun with the Command Line

Snow in the Terminal

Copy and paste the commands below into your bash shell to have it “snow” in your terminal. Make sure you have gawk installed. Standard awk will not work due to buffering problems.

sudo apt-get install pv
clear;while :;do echo $LINES $COLUMNS $(($RANDOM%$COLUMNS));sleep 0.1;done|gawk '{a[$3]=0;for(x in a) {o=a[x];a[x]=a[x]+1;printf "\033[%s;%sH ",o,x;printf "\033[%s;%sH*\033[0;0H",a[x],x;}}'
clear;while :;do echo $LINES $COLUMNS $(($RANDOM%$COLUMNS)) $(printf "\u2743\n");sleep 0.1;done|gawk '{a[$3]=0;for(x in a) {o=a[x];a[x]=a[x]+1;printf "\033[%s;%sH ",o,x;printf "\033[%s;%sH%s \033[0;0H",a[x],x,$4;}}'
for t in "Wake up" "The Matrix has you" "Follow the white rabbit" "Knock, knock";do pv -qL10 <<<$'\e[2J'$'\e[32m'$t$'\e[37m';sleep 5;done

Keep a cat entertained for hours.

while sleep $(($RANDOM % 10)); do eject -T /dev/cdrom;sleep 0.1; done

Unicode rainbow

for i in {1..65535};do printf "%x\n" $i;done|while read -r u;do printf "\033[38;5;$((16+$((16#$u))%230))m\u$u\033[0m";done

Quick popup notification command after 3 minutes.

sleep 3m; xmessage -nearmouse "Your tea is ready"

MATRIX Effect in the Terminal

echo -e "\e[1;40m" ; clear ; while :; do echo $LINES $COLUMNS $(( $RANDOM % $COLUMNS)) $(( $RANDOM % 72 )) ;sleep 0.05; done|gawk '{ letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()"; c=$4; letter=substr(letters,c,1);a[$3]=0;for (x in a) {o=a[x];a[x]=a[x]+1; printf "\033[%s;%sH\033[2;32m%s",o,x,letter; printf "\033[%s;%sH\033[1;37m%s\033[0;0H",a[x],x,letter;if (a[x] >= $1) { a[x]=0; } }}'
echo -e "\e[1;40m" ; clear ; characters=$( jot -c 94 33 | tr -d '\n' ) ; while :; do echo $LINES $COLUMNS $(( $RANDOM % $COLUMNS)) $(( $RANDOM % 72 )) $characters ;sleep 0.05; done|gawk '{ letters=$5; c=$4; letter=substr(letters,c,1);a[$3]=0;for (x in a) {o=a[x];a[x]=a[x]+1; printf "\033[%s;%sH\033[2;32m%s",o,x,letter; printf "\033[%s;%sH\033[1;37m%s\033[0;0H",a[x],x,letter;if (a[x] >= $1) { a[x]=0; } }}'
echo -e "\e[1;40m" ; clear ; while :; do echo $LINES $COLUMNS $(( $RANDOM % $COLUMNS)) $( printf "\U$(( $RANDOM % 500 ))" ) ;sleep 0.05; done|gawk '{c=$4; letter=$4;a[$3]=0;for (x in a) {o=a[x];a[x]=a[x]+1; printf "\033[%s;%sH\033[2;32m%s",o,x,letter; printf "\033[%s;%sH\033[1;37m%s\033[0;0H",a[x],x,letter;if (a[x] >= $1) { a[x]=0; } }}'

Make some waves. Req 256-color term.

yes "$(seq 19 21; seq 21 -1 18)" |while read i; do printf "\x1b[48;5;${i}m\n"; sleep .03; done

Starwars blinkenlights via Telnet

telnet towel.blinkenlights.nl

Disco lights in the terminal

while true; do printf "\e[38;5;$(($(od -d -N 2 -A n /dev/urandom)%$(tput colors)))m.\e[0m"; done

Furtune and cowsay

fortune | cowsay

What the commit and cowsay

wget -qO- http://whatthecommit.com/index.txt | cowsay

Matrix effect

apt-get install cmatrix
cmatrix

Fork Bomb

This is a very nasty piece of code. Run this at your own risk.

 :(){ :|:& }:

Twitter Status update

url -u YourUsername:YourPassword -d status="Your status message" http://twitter.com/statuses/update.xml

Spinning ASCII art globe.

curl -s http://artscene.textfiles\.com/vt100/globe.vt | pv -L9600 -q

Today’s famous birthdays

elinks -no-numbering -dump-width $COLUMNS $(date +"http://enwp.org/%B_%-d ")|sed '/Births/,/Deaths/!d'|grep \*

pulsed terminal clock

clear;while true;sleep 1;do for((a=1;a<=$(tput cols)/3;a++));do tput cup 0 $a;echo " " $(date);done;sleep 1;for((a;a>=1;a--));do tput cup 0 $a;echo $(date) " ";done;done

Labyrinth pattern Generates labyrinth-like pattern on UTF-8 terminal in bash.

while ( true ) ; do if [ $(expr $RANDOM % 2 ) -eq 0 ] ; then echo -ne "\xE2\x95\xB1" ; else echo -ne "\xE2\x95\xB2" ; fi ; done

Watching Superbowl via the command line

On host1 with video card device

cat /dev/video | nc -l -p 9998

on another host

nc host 9998 | mplayer -v  x11 --cache 3000 -

Binary clock

perl -e 'for(;;sleep 1){printf"\r"."%.4b "x6,split"",`date +%H%M%S`}'

Yet Another Large Screen Clock

clear; while sleep 1; do d=$(date +"%H:%M:%S"); e=$(echo "toilet -t -f mono12 $d");tput setaf 1 cup 0; eval $e; tput setaf 4 cup 8; eval "$e -F flop";tput cup 0; done

Display Spinner while waiting for some process to finish

while kill -0 0; do timeout 5 bash -c 'spinner=( Ooooo oOooo ooOoo oooOo ooooO oooOo ooOoo oOooo); while true; do for i in ${spinner[@]}; do for _ in seq 0 ${#i}; do echo -en "\b\b"; done; echo -ne "${i}"; sleep 0.2; done; done'; done

A talking clock with espeak

echo $(date +%m) past $(date +%H) | espeak
espeak -vde "Hallo ich bin ripley, was kann ich für sie tun?"

Chronometer

A way for tracking times in bash

stf=$(date +%s.%N);st=${stf/.*/};sn=%{stf/*./};for ((;;));do ctf=$( date +%s.%N );ct=${ctf/.*/};cn=${ctf/*./}; echo -en "\r$(echo "scale=3; $ctf-$stf" | bc)";done

On Hour Format

stf=$(date +%s.%N);st=${stf/.*/};sn=%{stf/*./};for ((;;));do ctf=$( date +%s.%N );ct=${ctf/.*/};cn=${ctf/*./}; dtf=$(echo "scale=3; $ctf-$stf" | bc); dt=${dtf/.*/}; dt=${dt:=0};echo -en "\r$(date -u -d @$dt "+%H:%M:%S.${dtf/*./}")";done

Links:

Last generation on 2024-12-26 00:22:52.


© 2024 Oliver Graute ⋅ hosted on a Raspberry PI ⋅ EmailMastodonTwitterGithubStackoverflowFlickr