From 8cd50fbf53eb34c284d4384ad7e2609eae15f031 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Fri, 10 Feb 2023 18:34:06 +0800 Subject: Update --- tools/misc/flash.sh | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'tools/misc/flash.sh') diff --git a/tools/misc/flash.sh b/tools/misc/flash.sh index bad8bb1..71d81a4 100755 --- a/tools/misc/flash.sh +++ b/tools/misc/flash.sh @@ -1,30 +1,33 @@ #! /bin/bash -CARD="$(cat ~/log/flashcards.md | shuf | head -1)" +while true; do + CARD="$(cat ~/log/flashcards.md | shuf | head -1)" -# Print the Question -<<<"$CARD" tr -s '\t' | cut -f1 -echo -echo ---- -echo + # Print the Question + <<<"$CARD" tr -s '\t' | cut -f1 + echo + echo ---- + echo -# Get the User Input -read -er INPUT + # Get the User Input + read -er INPUT -# Print the Answer -ANSER=$(<<<"$CARD" tr -s '\t' | cut -f2) -echo -echo ---- -echo + # 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 + # If answer correctly, print the checked box + if [[ "$INPUT" == "$ANSER" ]]; then + tput setaf 2 + echo '☑' + tput setaf 7 + else + echo $ANSER + fi -# Quit when getting Line Feed -read + echo + echo ---- + echo +done -- cgit v1.2.3-70-g09d2