diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2023-02-10 18:34:06 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2023-02-10 18:34:06 +0800 |
commit | 8cd50fbf53eb34c284d4384ad7e2609eae15f031 (patch) | |
tree | 29e1bb2c59b3071484a914e816fd6d7066a18b0a /tools | |
parent | e373f5c47c5f0b7ead90841cce36dcfa161baf7c (diff) |
Update
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/misc/flash.sh | 49 |
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 | ||
3 | CARD="$(cat ~/log/flashcards.md | shuf | head -1)" | 3 | while 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 |
7 | echo | 8 | echo |
8 | echo ---- | 9 | echo ---- |
9 | echo | 10 | echo |
10 | 11 | ||
11 | # Get the User Input | 12 | # Get the User Input |
12 | read -er INPUT | 13 | read -er INPUT |
13 | 14 | ||
14 | # Print the Answer | 15 | # Print the Answer |
15 | ANSER=$(<<<"$CARD" tr -s '\t' | cut -f2) | 16 | ANSER=$(<<<"$CARD" tr -s '\t' | cut -f2) |
16 | echo | 17 | echo |
17 | echo ---- | 18 | echo ---- |
18 | echo | 19 | echo |
19 | 20 | ||
20 | # If answer correctly, print the checked box | 21 | # If answer correctly, print the checked box |
21 | if [[ "$INPUT" == "$ANSER" ]]; then | 22 | if [[ "$INPUT" == "$ANSER" ]]; then |
22 | tput setaf 2 | 23 | tput setaf 2 |
23 | echo '☑' | 24 | echo '☑' |
24 | else | 25 | tput setaf 7 |
25 | tput setaf 1 | 26 | else |
26 | echo $ANSER | 27 | echo $ANSER |
27 | fi | 28 | fi |
28 | 29 | ||
29 | # Quit when getting Line Feed | 30 | echo |
30 | read | 31 | echo ---- |
32 | echo | ||
33 | done | ||