aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/misc/flash.sh
blob: 93ce8fdcfcdc85374c117ed8455e712f8bc19bf6 (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
31
32
33
34
35
36
37
38
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