From 6fae25b305d714b3ab7608fa003f1af9bf024545 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 14 Feb 2023 13:33:23 +0800 Subject: Rename tools into bin --- bin/misc/flash.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 bin/misc/flash.sh (limited to 'bin/misc/flash.sh') diff --git a/bin/misc/flash.sh b/bin/misc/flash.sh new file mode 100755 index 0000000..93ce8fd --- /dev/null +++ b/bin/misc/flash.sh @@ -0,0 +1,39 @@ +#! /bin/bash + +while true; do + CARDS="$(cat ~/log/flashcards.md | shuf | head -5)" + CARD="$(<<<"$CARDS" sed -n 3p)" + + # Print the Question + <<<"$CARD" tr -s '\t' | cut -f1 + echo + tput bold; tput setaf 1 + <<<"$CARDS" tr -s '\t' | cut -f2 | tr '\n' '\t' + tput sgr0 + echo + 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 '☑' + tput setaf 7 + else + echo $ANSER + fi + + echo + read + tput clear +done -- cgit v1.2.3-70-g09d2