aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin/misc/flash.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bin/misc/flash.sh')
-rwxr-xr-xbin/misc/flash.sh39
1 files changed, 39 insertions, 0 deletions
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 @@
1#! /bin/bash
2
3while true; do
4 CARDS="$(cat ~/log/flashcards.md | shuf | head -5)"
5 CARD="$(<<<"$CARDS" sed -n 3p)"
6
7 # Print the Question
8 <<<"$CARD" tr -s '\t' | cut -f1
9 echo
10 tput bold; tput setaf 1
11 <<<"$CARDS" tr -s '\t' | cut -f2 | tr '\n' '\t'
12 tput sgr0
13 echo
14 echo
15 echo ----
16 echo
17
18 # Get the User Input
19 read -er INPUT
20
21 # Print the Answer
22 ANSER=$(<<<"$CARD" tr -s '\t' | cut -f2)
23 echo
24 echo ----
25 echo
26
27 # If answer correctly, print the checked box
28 if [[ "$INPUT" == "$ANSER" ]]; then
29 tput setaf 2
30 echo '☑'
31 tput setaf 7
32 else
33 echo $ANSER
34 fi
35
36 echo
37 read
38 tput clear
39done