Apple - How to produce constant output in a Terminal window?

Pulling ideas from this unix.stackexchange.com Q&A about generating "hollywood" style terminal output.

The Slow Type

This script produces that delayed typing like effect you see in movies. Where the computer prints things in the terminal at some really awful and slow rate.

Save the following to a file named hollywood:

#!/bin/bash

while IFS= read -r line; do
    length="${#line}"
    bol=1
    for (( offset = 0 ; offset < length ; offset++ )); do
        char="${line:offset:1}"
        printf '%s' "$char"
        if (( bol )) && [[ "$char" == " " ]]; then
            continue
        fi
        bol=0
        sleep 0.05
    done

    if (( length == 0 )); then
        sleep 0.$(( RANDOM % 3 + 2 ))
    else
        sleep 0.$(( RANDOM % 7 + 3 ))
    fi

    printf '\n'
done

Set execute permissions on the file hollywood:

chmod +x hollywood

And then pipe it the output from dmesg to give it a large chunk of snazzy looking text to slowly print on the screen:

dmesg | hollywood

The Hex Dump

This dumps hex data to the screen. Looks impressive but is largely unintelligible to the masses.

hexdump -C /dev/urandom | GREP_COLOR='1;32' grep --color=auto 'ca fe'

The Matrix

Numbers. Numbers everywhere.

LC_CTYPE=C tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"

Unfortunately, with that one there isn't a good way to control the speed.

There's a better version of this available view Homebrew called cmatrix. You can install and run it with:

brew install cmatrix
cmatrix

If you have some files that are growing you can use tail -f. For example

 $ tail -f /var/log/system.log

There are several terminal tools similar to activity monitor, for example top (delivered with OS X) and htop (you will have to install it with MacPorts or Homebrew).

You could also download the sources of a large software package (e.g., gcc, OpenOffice) and then compile it. This will usually generate a lot of output on the console.

You could also generate huge directory listings

$ ls -lRt

or find (the second one will delay each line by one second)

$ find .
$ find . -print -exec sleep 1 \;

The matrix command:

od -c /dev/random

Read carefully, at a given time you will see the secret key.

Tags:

Terminal