Skip to content

Instantly share code, notes, and snippets.

@arai-ta
Created May 9, 2021 18:10
Show Gist options
  • Save arai-ta/8a95c1a7a81bb2eaf204552969e434f4 to your computer and use it in GitHub Desktop.
Save arai-ta/8a95c1a7a81bb2eaf204552969e434f4 to your computer and use it in GitHub Desktop.
新しいキーボードでコマンドの練習をするためのスクリプト
#!/bin/sh
TMPFILE=/tmp/`basename $0`.tmp
if [ $# = 0 ]
then
echo "Usage: `basename $0` " '$HISTFILE'
exit 1
fi
export LANG=C
cat ${1:?} | sort | uniq -c | sort -k1r | awk '$1 >= 10{sub(/^ *[0-9]+ +/,"");sub(/ +$/,"");print}' > $TMPFILE
echo "Let's type your frequently used command. (@ to skip)"
IFS=$'\n'
for cmd in `cat $TMPFILE`
do
while :
do
echo "[ $cmd ]"
printf ">>> "
read TYPE
if [ "$TYPE" = "$cmd" ]
then
echo "OK, go next"
break
elif [ "$TYPE" = "@" ]
then
echo "Skipping..."
break
else
echo "Poor! try again!"
fi
done
done
rm $TMPFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment