From 920522b21376a94347fd8757b375800d0fac77fe Mon Sep 17 00:00:00 2001 From: Wrongthink Date: Sun, 23 Apr 2023 00:20:36 +0900 Subject: [PATCH] Initial upload --- flashcard.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 flashcard.sh diff --git a/flashcard.sh b/flashcard.sh new file mode 100644 index 0000000..dcf65d3 --- /dev/null +++ b/flashcard.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +#Enumerate memorization items +for item in `cut -f 1 "$1"`; do + front+=($item) +done + +#Enuerate answers +for item in `cut -f 2 "$1" | sed -e 's: :_:g'`; do + back+=($item) +done + +#Generate random flash card order +order=$(shuf -e $(seq 0 $(expr ${#front[@]} \- 1))) + +flashcards(){ +for card in ${order[@]}; do + whiptail --msgbox "Unmemorized ${#repeat[@]} \n\n ${front[$card]} |" --ok-button "Show" 15 60 + whiptail --yesno "Unmemorized ${#repeat[@]} \n\n ${front[$card]} | ${back[$card]}" --yes-button "Know" --no-button "Don't know" 15 60 + #Catalogue unmemorized cards + if [[ $? = 1 ]]; then + repeat+=($card) + fi +done +#Load unmemorized cards back into deck and repeat +if [[ "${#repeat[@]}" > 0 ]]; then + order="${repeat[@]}" + unset repeat + flashcards +else + exit 0 +fi +} + +flashcards + +exit 0