Last active
April 4, 2022 15:21
-
-
Save KaeruCT/4688138 to your computer and use it in GitHub Desktop.
hackertyper.com on your bash shell
This file contains 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 | |
if [ ! -r "$1" ]; then | |
echo "Please provide a valid file." | |
exit 0 | |
fi | |
file="$(<$1)" | |
length="${#file}" | |
speed=4 | |
char_count=0 | |
for (( i=0; i<$length; i++ )) do | |
if [ $char_count -eq 0 ]; then | |
char_count=$speed | |
old_tty_setting=$(stty -g) | |
stty -icanon -echo | |
key=$(dd bs=1 count=1 2> /dev/null) | |
stty "$old_tty_setting" | |
fi | |
((char_count--)) | |
printf "${file:i:1}" | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment