Skip to content

Instantly share code, notes, and snippets.

@ianyon
Last active September 25, 2015 03:30
Show Gist options
  • Save ianyon/e707f71d67ffacfcdd07 to your computer and use it in GitHub Desktop.
Save ianyon/e707f71d67ffacfcdd07 to your computer and use it in GitHub Desktop.
Function for ".bashrc" that works like HackerTyper
#!/bin/bash
###########################################################################
# Prints source code in screen when pressing any key
# Arguments:
# $1: Extension of the files, without "."
# $2 (optional): Number of characters to print with each keystroke.
# Default 10
# $3 (optional): Filename or path of files to print
###########################################################################
hackertyper () {
lines=10
if [ "$2" ]
then
lines=$2
fi
filename=.
if [ "$3" ]
then
filename=$3
fi
EXT="."$1;
for F in $(find $filename -iname "*$EXT" -nowarn -readable 2> /dev/null)
do
cat $F | \
while IFS= read -rN $lines C
do
read -s -n 1 <&1
echo -n "$C"
done
echo
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment