aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/misc/flash.sh
blob: bad8bb17bdc9029ffa32434cc0f1d9dfae5e47c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#! /bin/bash

CARD="$(cat ~/log/flashcards.md | shuf | head -1)"

# Print the Question
<<<"$CARD" tr -s '\t' | cut -f1
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 '☑'
else
  tput setaf 1
  echo $ANSER
fi

# Quit when getting Line Feed
read