aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2023-02-10 18:34:06 +0800
committerHsieh Chin Fan <pham@topo.tw>2023-02-10 18:34:06 +0800
commit8cd50fbf53eb34c284d4384ad7e2609eae15f031 (patch)
tree29e1bb2c59b3071484a914e816fd6d7066a18b0a /tools
parente373f5c47c5f0b7ead90841cce36dcfa161baf7c (diff)
Update
Diffstat (limited to 'tools')
-rwxr-xr-xtools/misc/flash.sh49
1 files changed, 26 insertions, 23 deletions
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 @@
1#! /bin/bash 1#! /bin/bash
2 2
3CARD="$(cat ~/log/flashcards.md | shuf | head -1)" 3while true; do
4 CARD="$(cat ~/log/flashcards.md | shuf | head -1)"
4 5
5# Print the Question 6 # Print the Question
6<<<"$CARD" tr -s '\t' | cut -f1 7 <<<"$CARD" tr -s '\t' | cut -f1
7echo 8 echo
8echo ---- 9 echo ----
9echo 10 echo
10 11
11# Get the User Input 12 # Get the User Input
12read -er INPUT 13 read -er INPUT
13 14
14# Print the Answer 15 # Print the Answer
15ANSER=$(<<<"$CARD" tr -s '\t' | cut -f2) 16 ANSER=$(<<<"$CARD" tr -s '\t' | cut -f2)
16echo 17 echo
17echo ---- 18 echo ----
18echo 19 echo
19 20
20# If answer correctly, print the checked box 21 # If answer correctly, print the checked box
21if [[ "$INPUT" == "$ANSER" ]]; then 22 if [[ "$INPUT" == "$ANSER" ]]; then
22 tput setaf 2 23 tput setaf 2
23 echo '☑' 24 echo '☑'
24else 25 tput setaf 7
25 tput setaf 1 26 else
26 echo $ANSER 27 echo $ANSER
27fi 28 fi
28 29
29# Quit when getting Line Feed 30 echo
30read 31 echo ----
32 echo
33done