From e373f5c47c5f0b7ead90841cce36dcfa161baf7c Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Fri, 10 Feb 2023 14:42:14 +0800 Subject: Update --- tools/misc/flash.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 tools/misc/flash.sh (limited to 'tools/misc/flash.sh') diff --git a/tools/misc/flash.sh b/tools/misc/flash.sh new file mode 100755 index 0000000..bad8bb1 --- /dev/null +++ b/tools/misc/flash.sh @@ -0,0 +1,30 @@ +#! /bin/bash + +CARD="$(cat ~/log/flashcards.md | shuf | head -1)" + +# Print the Question +<<<"$CARD" tr -s '\t' | cut -f1 +echo +echo ---- +echo + +# Get the User Input +read -er INPUT + +# Print the Answer +ANSER=$(<<<"$CARD" tr -s '\t' | cut -f2) +echo +echo ---- +echo + +# If answer correctly, print the checked box +if [[ "$INPUT" == "$ANSER" ]]; then + tput setaf 2 + echo '☑' +else + tput setaf 1 + echo $ANSER +fi + +# Quit when getting Line Feed +read -- cgit v1.2.3-70-g09d2