Compare commits

..

No commits in common. "master" and "v1.0" have entirely different histories.
master ... v1.0

9 changed files with 93 additions and 350 deletions

2
.github/FUNDING.yml vendored
View File

@ -1,5 +1,5 @@
# These are supported funding model platforms # These are supported funding model platforms
patreon: bryanjenks patreon: bryanjenks
github: tallguyjenks
custom: ["https://www.buymeacoffee.com/tallguyjenks", "https://www.paypal.me/tallguyjenks"] custom: ["https://www.buymeacoffee.com/tallguyjenks", "https://www.paypal.me/tallguyjenks"]

View File

@ -28,13 +28,6 @@ If applicable, add screenshots to help explain your problem.
- Terminal Emulator [e.g. st, kitty, etc] - Terminal Emulator [e.g. st, kitty, etc]
- Shell [e.g. bash, zsh, fish] - Shell [e.g. bash, zsh, fish]
## Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context** **Additional context**
Add any other context about the problem here. Add any other context about the problem here.

View File

@ -1,13 +0,0 @@
name: Greetings
on: [pull_request, issues]
jobs:
greeting:
runs-on: ubuntu-latest
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: 'This was your first issue! Thank you for contributing!'' first issue'
pr-message: 'This was your first Pull Request! Thank you for contributing!'' first pr'

View File

@ -1,17 +0,0 @@
# from here: https://github.com/marketplace/actions/shellcheck
on:
push:
branch:
- master
name: 'Trigger: Push action'
jobs:
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: ShellCheck
uses: ludeeus/action-shellcheck@1.0.0

View File

@ -1,19 +0,0 @@
name: Mark stale issues and pull requests
on:
schedule:
- cron: "30 1 * * *"
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Stale issue message'
stale-pr-message: 'Stale pull request message'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'

View File

@ -1,17 +1,12 @@
<!-- Shields --> <!-- Header & Preview Image -->
<p align="center"> <h1 align="center">
<a href="https://github.com/tallguyjenks/fla.sh/blob/master/LICENSE"><img src="https://img.shields.io/static/v1.svg?style=flat&label=License&message=MIT&logoColor=eceff4&logo=github&colorA=black&colorB=green"/></a> <img src="/img/flashheader.png" height="50%" width="50%">
<img src="https://img.shields.io/github/commit-activity/m/tallguyjenks/fla.sh"> </h1>
<a href="https://github.com/tallguyjenks/fla.sh/graphs/contributors"><img src="https://img.shields.io/github/contributors/tallguyjenks/fla.sh"></a>
<img src="https://img.shields.io/github/v/release/tallguyjenks/fla.sh">
</p>
<!-- Description --> <!-- Description -->
> Flashcards in your terminal! > flashcards in your terminal! This script was inspired by a basic script i saw in a youtube video by a user named nixcasts. I Like the Anki flashcard system and so im working to replicate it in a simple manner using plain text documents and a shell script to aid my ability to study with active recall and spaced repetition.
>
> This script was inspired by a basic script that I had seen in a youtube video by a user named nixcasts. I like the Anki flashcard system, hence I'm working to replicate it in a simple manner using plain text documents and a shell script to aid my ability to study with active recall and spaced repetition.
![Preview of fla.sh](./img/flash_preview.png) ![Preview of flash.sh](./img/flash_preview.png)
This script is an expanded version of the one featured in [This nixcasts Video](https://www.youtube.com/watch?v=lX8jqo70r1I) This script is an expanded version of the one featured in [This nixcasts Video](https://www.youtube.com/watch?v=lX8jqo70r1I)
@ -24,39 +19,14 @@ You can have as many 'decks' in the `flash` directory as you want, and having di
This script uses: This script uses:
- [fzf](https://github.com/junegunn/fzf) - [fzf](https://github.com/junegunn/fzf)
- [bat](https://github.com/sharkdp/bat) (optional if you use `flash -p cat` to use the core utility instead of `bat`) - [bat](https://github.com/sharkdp/bat)
- (if on macOS the GNU core utilities are a dependency (namely the `shuf` utility))
Install these prior to running the script. Install these prior to running the script.
## Installation ## Installation
### Windows
Untested, not sure if this script and its dependencies will work with WSL or not.
### Mac
Will need to have `brew` to install dependencies listed below and also `brew install coreutils` to get the GNU core utilities as `shuf` is not in macOS by default.
You will need to put the script itself somewhere in your `$PATH` and execute it to initialize the setup.
Confirmed to work on macOS 10.14.6 more recent version welcome to test and file an issue/pull request to update README if other versions run the script as it should.
### Linux
To utilize this script copy/move it to your `~/.local/bin/` folder or any place in your `$PATH` To utilize this script copy/move it to your `~/.local/bin/` folder or any place in your `$PATH`
## Troubleshooting
> Common issues will be added here as they arise during the stability stage of this script.
Checks:
- Is your system supported? see above
- Are all necessary dependencies installed?
- what version of bash do you have installed? or do you have bash installed?
## Usage ## Usage
The `deck.csv` file should have colon `:` separated values in 4 columns The `deck.csv` file should have colon `:` separated values in 4 columns
@ -73,18 +43,17 @@ Organized like this:
**Fourth Field:** _The Score*_ **Fourth Field:** _The Score*_
> \* The score determines how often and which cards are shown to you. A good idea is to start all your cards out at 0 so that all are served to you equally. As you study, review, and mark the more familiar cards as 'Mild' or 'Easy', more points will be added. The lower point cards are sorted to the top and the top 10 are taken, shuffled, and then drawn from. This way as you learn the material and the items you are less familiar with bubble up into the shuffled pool for drawing and those that go up in points due to increased familiarity go down because you're rating the material as easier. > \* The score determines how often which cards are shown to you. A good idea is to start all your cards out at 0 so they are all served to you equally. As you study and review and mark the more familiar cards as 'Mild' or 'Easy' more points will be added. The lower point cards are sorted to the top and the top 10 are taken and shuffled and then drawn from. This way as you learn the material the items you are less familiar with bubble up into the shuffled pool for drawing and those that go up in points due to increased familiarity go down because you're rating the material as easier.
### Decks ### Decks
If you would like to browse through a collection of decks readily available in your subject matter that are comaptible with [fla.sh](https://github.com/tallguyjenks/fla.sh) then you should check out [Flash Decks](https://github.com/tallguyjenks/Flash-Decks). If you would like to browse a collection of decks readily available in your subject matter that are comaptible with [flash.sh](https://github.com/tallguyjenks/flash.sh) then you should check out [Flash Decks](https://github.com/tallguyjenks/Flash-Decks).
## Media (accepting contributions) ## Media (accepting contributions)
- [Fla.sh Plain Text Flashcards in your Terminal](https://www.youtube.com/watch?v=DbakjEAc_MU) - [(OLD)Flash.sh Plain Text Flashcards in your Terminal](https://www.youtube.com/watch?v=DbakjEAc_MU)
- [Flash Cards In Your Terminal With Fla.sh](https://www.youtube.com/watch?v=KEWhOzDCfLg) - [Flash Cards In Your Terminal With Flash.sh](https://www.youtube.com/watch?v=KEWhOzDCfLg)
- [Fla.sh++ A Comprehensive Walk Through of My Bash Flashcard Script Project](https://www.youtube.com/watch?v=nPNPXEh6BUA) - [Flash.sh++ A Comprehensive Walk Through of My Bash Flashcard Script Project](https://www.youtube.com/watch?v=nPNPXEh6BUA)
- [Even Exam Prep Can Be Done From The Terminal With Fla.sh](https://www.youtube.com/watch?v=RJ094P7wxaU)
## Support ## Support
@ -100,3 +69,5 @@ This is free, open-source software. If you'd like to support the development of
<img src="/img/flashfooter.png"> <img src="/img/flashfooter.png">
</h3> </h3>
<!-- Shields -->
<p align="center"><a href="https://github.com/tallguyjenks/flash.sh/blob/master/LICENSE"><img src="https://img.shields.io/static/v1.svg?style=flat-square&label=License&message=MIT&logoColor=eceff4&logo=github&colorA=black&colorB=green"/></a></p>

324
flash
View File

@ -23,322 +23,150 @@
# bat - https://github.com/sharkdp/bat # bat - https://github.com/sharkdp/bat
#==============================================================# #==============================================================#
# USER CUSTOMIZABLE VARIABLES #ANSI FOREGROUND ESCAPE COLORS
CARD_POOL_SIZE=10 ######## How large the pool size is for shuf to draw from
SEARCH_DEPTH=999 ######### How many levels to recursively search for .csv's in .local/share/flash
PREVIEWER='bat' ########## What fzf previewer to use when searching through decks
CURR_DECK_DISPLAY="file" # Options are 'file' or 'path'
# ANSI FOREGROUND ESCAPE COLORS
RED='\033[0;31m' RED='\033[0;31m'
LRED='\033[1;31m' LRED='\033[1;31m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
LGREEN='\033[1;32m' LGREEN='\033[1;32m'
LBLUE='\033[1;34m'
CYAN='\033[0;36m'
LCYAN='\033[1;36m'
ORANGE='\033[0;33m' ORANGE='\033[0;33m'
LGREY='\033[0;37m' LGREY='\033[0;37m'
WHITE='\033[1;37m' WHITE='\033[1;37m'
NC='\033[0m' # No Color NC='\033[0m' # No Color
# ANSI BACKGROUND ESCAPE COLORS #ANSI BACKGROUND ESCAPE COLORS
WHITEBG='\033[1;47m' WHITEBG='\033[1;47m'
# FONT FORMAT EXCAPE CODES # FONT FORMAT EXCAPE CODES
BOLD='\e[1m' BOLD='\e[1m'
# Remember User's Starting Directory PWD="$(pwd)" # Remember User's Starting Directory
PWD="$(pwd)" DIR="$HOME/.local/share/flash" # Where Decks Are Located
# Where Decks Are Located for linux & mac EXAMPLE_DECK="$HOME/.local/share/flash/deck.csv"
# Prefer XDG Configuration before hard coded file paths
OS="$(uname)"
case "$OS" in
"Darwin") DIR="${XDG_DATA_HOME:-$HOME/Library/Application Support}/flash" && alias shuf=gshuf ;;
"Linux") DIR="${XDG_DATA_HOME:-$HOME/.local/share}/flash" ;;
*) DIR="${XDG_DATA_HOME:-$HOME/.local/share}/flash" ;;
esac
# Where the example deck will be placed and named
EXAMPLE_DECK="$DIR/deck.csv"
# Track High score
HIGH_SCORE="$DIR/.highscore"
# Track number of cards reviewed per session
REVIEW_LOG="$DIR/.reviews"
# Iterator for Count of cards reveiwed
COUNTER=0 COUNTER=0
# Success message of setup process
DIR_MADE_MSG=" DIR_MADE_MSG="
Your ${LRED}$DIR${NC} directory has been made and Your ${LRED}~/.local/share/flash${NC} directory has been made and
your ${ORANGE}deck.csv${NC} file is ready for you to enter your flashcard data your ${ORANGE}deck.csv${NC} file is ready for you to enter your flashcard data
If you want to see information about ${ORANGE}fla.sh${NC} then use the option
${YELLOW}flash -i${NC}.
" "
# User has .local/share directory but no decks inside
NO_DECKS=" NO_DECKS="
No decks were found, please make a new deck No decks were found, please make a new deck
using ${ORANGE}:${NC} as a delimiter in a ${ORANGE}.csv${NC} file in using ${ORANGE}:${NC} as a delimiter in a ${ORANGE}.csv${NC} file in
the ${LRED}$DIR${NC} directory. the ${LRED}.local/share/flash${NC} directory.
An example of a card: An example of a card:
${GREEN}Math:What is the square root of 4?:2:0${NC} ${GREEN}Math:What is the square root of 4?:2:0${NC}
" "
# The example flashcard deck to be made
DECK_TEMPLATE="History:When was the declaration of independence signed?:1776:0 DECK_TEMPLATE="History:When was the declaration of independence signed?:1776:0
Math:What is the square root of 4?:2:4 Math:What is the square root of 4?:2:4
Science:What is the charge on a proton?:Positive 1:2 Science:What is the charge of a proton?:Positive:2
Philosophy:What was Socrates known as?:The Gadfly of Athens:0 Philosophy:What was socrates known as?:The Gadfly of Athens:0
Programming:What is the typical starting index of an array?:0:5 Programming:What is the typical starting value of an array?:0:5
History:What did Abraham Lincoln typically keep in his hat?:Mail:0 History:What did Abraham Lincoln Typically Keep In his hat?:Mail:0
Math:What is the value of PI to 2 decimal places?:3.14:4 Math:what is the first 2 decimal places of PI:3.14:4
Science:What is the charge on an electron?:Negative 1:3 Science:What is the charge of an electron?:Negative:3
Programming:What does OOP stand for?:Object Oriented Programming:2 Programming:What does OOP stand for?:Object Oriented Programming:2
History:What did Socrates drink to commit suicide?:Hemlock Tea:2 History:What did socrates drink to commit suicide?:Hemlock Tea:2
Math:What is the general equation for the slope of a line?:y=mx+b:4 Math:What is the equation for a slope of a line?:y=mx+b:4
Science:What is the charge on a neutron?:Neutral:1 Science:What is the charge of a neutron?:Neutral:1
Programming:What is Vim?:God's Text Editor:999 Programming:What is Vim?:God's Text Editor:999
History:What were the British known by during the American Revolution?:The Redcoats:1 History:What were the british known buy during the american revolution?:The redcoats:1
Math:What is the value of this equation - log10(100)?:2:0 Math:What is the value of this equation - log10(100)?:2:0
Science:What are protons and neutrons made of?:quarks:5 Science:What are protons/neutrons/electrons made of?:quarks:5
Programming:What does RAM stand for?:Random Access Memory:1 Programming:What does RAM stand for?:Random Access Memory:1
History:What was the year 2000 also known as?:Y2K:0 History:What was the year 2000 also known as?:Y2K:0
Math:What is the formula for the mean?:Sum/count:4 Math:What is the formula for mean?:Sum/count:4
Science:What is cold?:The absense of heat:3 Science:What is cold?:The absense of heat:3
Programming:What languages are the worst?:Proprietary:999 Programming:What languages are the worst?:Proprietary:999
History:When did man land on the moon?:1969:4 History:When did man land on the moon?:1969:4
Math:10^3=?:1000:1 Math:10^3=?:1000:1
Science:The _____ ______ Project mapped all of man's genes.:Human Genome:3 Science:The _____ ______ Project mapped all of man's genes.:Human Genome:3
Programming:What is the best computer to program on?:Thinkpad:999 Programming:What is the best computer to program on?:Thinkpad:999
History:When was fla.sh created?:April 2020:999 History:When was flash.sh created?:April 2020:999
Math:What do you call a number only divisible by itself and 1?:Prime:0 Math:What do you call a number only divisible by itself and 1?:Prime:0
Science:What is the distance between the Earth and Sol called?:An Astronomical Unit (AU):1 Science:What is the distance between the Earth and Sol called?:An Astronomical Unit (AU):1
Programming:What is the best operating system?:Arch, because BTW i run Arch:999" Programming:Best operating system?:Arch, because BTW i run Arch:999"
# Define setup process in a function and create necessary files for user if [ ! -d $DIR ];then # If Directory does NOT exist
setup() { echo -e "No ${LRED}.local/share/flash${NC} directory, make it? ${LGREEN}y${NC}/${LRED}n${NC}"
mkdir "$DIR" &&
touch {"$EXAMPLE_DECK","$HIGH_SCORE","$REVIEW_LOG"} &&
echo "$DECK_TEMPLATE" >>"$EXAMPLE_DECK" &&
echo -e "$DIR_MADE_MSG"
}
# Test if .local/share exists and wether to offer setup process
if [ ! -d "$DIR" ]; then
echo -e "No ${LRED}$DIR${NC} directory, make it? ${LGREEN}Y${NC}/${LRED}N${NC}"
# shellcheck disable=SC2162
read RESPONSE read RESPONSE
case "$RESPONSE" in case "$RESPONSE" in
[QqNn]) exit 0 ;; [QqNn]) exit ;;
[Yy]) setup && exit 0 ;; [Yy]) mkdir "$DIR" && touch $EXAMPLE_DECK && echo "$DECK_TEMPLATE" >> $EXAMPLE_DECK && echo -e "$DIR_MADE_MSG" && exit;;
*) >&2 echo -e "invalid choice, please select either ${LGREEN}y${NC} or ${LRED}n${NC}" && exit 1 ;; *) echo -e "invalid choice, please select either ${LGREEN}y${NC} or ${LRED}n${NC}" && exit ;;
esac esac
fi fi
# go to the flashcard decks directory cd "$DIR"
cd "$DIR" || exit 1
# If there are no flashcard decks available return user to starting location if [ "$(find -maxdepth 999 -iname "*.csv" | wc -l)" = 0 ]; then # If there are no flashcard decks available
# while also displaying explanatory text of issue echo -e "$NO_DECKS" && cd "$PWD" && exit
[ "$(find . -maxdepth "$SEARCH_DEPTH" -iname "*.csv" | wc -l)" = 0 ] && fi
>&2 echo -e "$NO_DECKS" && exit 1
# if highscore file was removed, remake it. # Show pretty FZF preview of decks using BAT
[ ! -e "$HIGH_SCORE" ] && touch "$HIGH_SCORE" DECK="$(find -maxdepth 999 -iname "*.csv" | fzf --preview='bat --theme="Solarized (dark)" --style=numbers --color=always {} | head -500')"
if [ -z $DECK ]; then # If Variable String Length is 0
exit
fi
# if reviewed file was removed, remake it. main(){
[ ! -e "$REVIEW_LOG" ] && touch "$REVIEW_LOG" IFS=$':'; read -a q <<<$(sort "$DECK" -n --field-separator=: --key=4 | head | shuf -n 1)
clear
print_usage() { echo -e "${WHITEBG} Flash.sh - Flash Cards In Your Terminal ${NC}"
echo -e "\n${LCYAN}fla.sh --- Flash card system by Bryan Jenks${NC} ${LBLUE}<BryanJenks@protonmail.com>${NC}\n\n${YELLOW}${BOLD}Usage:${NC}\n\t${GREEN}flash -h:${NC} Print this help text\n\t${GREEN}flash -i:${NC} Print Information about the flashcard system\n\t${GREEN}flash -v:${NC} Print version Number\n\t${GREEN}flash -p [BINARY]:${NC} Change the previewer when selecting decks.\n\t\tDefault: ${GREEN}bat${NC}\n\t\tSupported: ${GREEN}bat${NC}, ${GREEN}cat${NC}\n" echo -e "${ORANGE}${BOLD}Cards ${BOLD}Reviewed:${NC} $COUNTER"
} echo -e "${LGREY}Category:${NC}
${q[0]}"
print_info() { echo -e "${LGREY}Question:${NC}
echo -e "\nThis flash card system works via colon ${YELLOW}:${NC} separated ${YELLOW}.csv${NC} files\n ${q[1]}"
with entries that look like this: ${LGREY}category:question:answer:0${NC}\n echo -e ""
These ${YELLOW}.csv${NC} files should be stored in your read -sn 1 NEXT
if [ "$NEXT" = q ]; then
\t${YELLOW}\$XDG_DATA_HOME/flash${NC} cd "$PWD" && exit
OR
\t${YELLOW}~/.local/share/flash${NC} for Linux
\t${YELLOW}~/Library/Application Support/flash${NC} for mac
-------------------------------------------------------------------------------
${LCYAN}Exiting:${NC}\n
\tYou can exit the application at any time by pressing either ${RED}q${NC} or ${RED}Q${NC}
${LCYAN}Usage:${NC}\n
\tYou will first be prompted with a question and will need to press ${RED}[Enter]${NC}
\tto reveal the answer. Once the answer is revealed you will need to either
\tquit, or give a rating to how difficult the question was.
${LCYAN}The Scoring System:${NC}\n
\tThe last field in the ${YELLOW}.csv${NC} files is the current point score of the 'card'
\tEvery time you rate a card the point score will either increase, decrease,
\tor stay the same. zero is the lowest value, and the upper limit is over
\t100 billion.
\t${CYAN}Scoring Results:${NC}
\t\t[${LRED}Hard${NC}]\t\t-2 points
\t\t[${RED}Difficult${NC}]\t-1 point
\t\t[${YELLOW}Normal${NC}]\tNo Change
\t\t[${GREEN}Mild${NC}]\t\t+1 point
\t\t[${LGREEN}Easy${NC}]\t\t+2 points
\tThe cards with the lowest scores (you scored them as ${LRED}Hard${NC}/${RED}Difficult${NC}) are
\tsorted to the top, a pool of them are picked and from that pool 1 card is
\trandomly drawn. As you become more familair with the material and rate it
\tas easier, the point values will go up and the cards will appear less
\tfrequently making room for those cards that are still difficult and have
\tlower point values.
It is a good idea to start all cards off at ${YELLOW}0${NC} initially so that they all
have an equal chance of being drawn initially.
"
}
while getopts 'hivp:' flag; do
case "${flag}" in
h) print_usage && exit 0 ;;
i) print_info && exit 0 ;;
v) echo -e "\n${YELLOW}fla.sh Current Version:${NC} ${RED}1.2${NC}\n" && exit 0 ;;
p) { [[ $(command -v "$OPTARG" 2>&1) ]] && PREVIEWER=$OPTARG; } || >&2 echo "Unable to find previewer $OPTARG. Exiting..." && exit 1 ;;
*) print_usage && exit 1 ;;
esac
done
# Set some parameters for preview command used by FZF
while [ -z "$PREVIEWER_PARAMTERS" ]; do
case "$PREVIEWER" in
bat) PREVIEWER_PARAMTERS="--theme='Solarized (dark)' --style=numbers --color=always" ;;
cat) PREVIEWER_PARAMTERS="-b" ;;
*) echo -e "${RED}$PREVIEWER${NC} is not a valid previewer. Use '${GREEN}bat${NC}' or '${GREEN}cat${NC}'. Falling back on default...\n" && read -r -s -p 'Press [Enter] to continue...' && echo -e "\n" && PREVIEWER='bat' ;;
esac
done
# Show pretty FZF preview of decks using $PREVIEWER. Default: BAT
DECK="$(find . -maxdepth "$SEARCH_DEPTH" -iname "*.csv" | fzf --preview="$PREVIEWER $PREVIEWER_PARAMTERS {} | head -500")"
# Get current deck name for display
case "$CURR_DECK_DISPLAY" in
file) CURRENT_DECK="$(echo "$DECK" | awk -F/ '{print $NF}')" ;;
path) CURRENT_DECK="$DECK" ;;
*) CURRENT_DECK="$(echo "$DECK" | awk -F/ '{print $NF}')" ;;
esac
# The top part of the flash display so that code is not duplicated twice
print_head() {
QUESTION=$(echo "${q[1]}" | fold -w 59)
echo -e "${WHITEBG} Fla.sh - Flash Cards In Your Terminal ${NC}
${ORANGE}${BOLD} Current Deck:${BOLD}${NC}\t$(basename -s .csv "$CURRENT_DECK")
${ORANGE}${BOLD}Cards Reviewed:${BOLD}${NC}\t$COUNTER
\t${ORANGE}${BOLD}High Score:${BOLD}${NC}\t$(cat "$HIGH_SCORE")
\t${ORANGE}${BOLD}Avg review:${BOLD}${NC}\t$(awk '{ sum += $7; n++ } END { if (n > 0) print sum / n; }' "$REVIEW_LOG")
${LGREY}Category:${NC} ${q[0]}
___________________________________________________________
$([ ${#QUESTION} -lt 59 ] && printf "%$(((59 - ${#QUESTION}) / 2))s")$QUESTION"
}
# Creating new entries in the log for the average score generation
add_usage_entry() {
if [ ! "$COUNTER" = 0 ]; then
# Create a New Entry
TIME_STAMP=$(date +"%Y%m%d %H:%M:%S")
printf -v ENTRY "TimeStamp: %s Deck: %s cardsReviewed: %s" "$TIME_STAMP" "$CURRENT_DECK" "$COUNTER"
echo "$ENTRY" >>"$REVIEW_LOG"
fi fi
} echo -e "${LGREY}Answer:${NC}
${q[2]}"
# If no deck is selected in fzf menu echo -e ""
# return user to start location echo -e "${WHITEBG}${WHITE}===========================================================${NC}"
# and exit quietly echo -e ""
[ -z "$DECK" ] && clear && exit 1 echo -e "${LGREY}How Difficult Was This Question?${NC}"
echo -e ""
main() { echo -e "${LRED}Hard${NC} [1] ${RED}Difficult${NC} [2] ${YELLOW}Normal${NC} [3] ${GREEN}Mild${NC} [4] ${LGREEN}Easy${NC} [5]"
IFS=$':' echo -e ""
# shellcheck disable=SC2162
read -a q <<<"$(sort "$DECK" -n --field-separator=: --key=4 | head -n "$CARD_POOL_SIZE" | shuf -n 1)"
clear
print_head
echo -e "
${LGREY}──────────────── Press [Enter] to continue ────────────────${NC}"
# shellcheck disable=SC2162
read -sn 1 NEXT
while [ ! "$NEXT" = "" ] && [ ! "$NEXT" = q ] && [ ! "$NEXT" = Q ]; do
# shellcheck disable=SC2162
read -sn 1 NEXT
done
clear
print_head
{ [ "$NEXT" = q ] || [ "$NEXT" = Q ]; } && add_usage_entry && clear && exit 0
ANSWER=$(echo "${q[2]}" | fold -w 59)
echo -e "___________________________________________________________
$([ ${#ANSWER} -lt 59 ] && printf "%$(((59 - ${#ANSWER}) / 2))s")$ANSWER
${WHITEBG}${WHITE}===========================================================${NC}
${LGREY}How Difficult Was This Question?${NC}
${LRED}Hard${NC} [1] ${RED}Difficult${NC} [2] ${YELLOW}Normal${NC} [3] ${GREEN}Mild${NC} [4] ${LGREEN}Easy${NC} [5]
${LGREY}Select a number to continue, or${NC} ${LRED}Q${NC} ${LGREY}to quit...${NC}"
# shellcheck disable=SC2162
read -sn 1 DIFFICULTY_SCORE read -sn 1 DIFFICULTY_SCORE
while [[ ! "$DIFFICULTY_SCORE" =~ [12345qQ] ]]; do
# shellcheck disable=SC2162
read -sn 1 DIFFICULTY_SCORE
done
{ [ "$DIFFICULTY_SCORE" = q ] || [ "$DIFFICULTY_SCORE" = Q ]; } &&
add_usage_entry && clear && exit 0
clear clear
COUNTER="$((COUNTER + 1))" # Increment count for card review count increment COUNTER="$(($COUNTER+1))" # Increment count for above test and card review count increment
if [ "${q[3]}" = 0 ]; then if [ "${q[3]}" = 0 ]; then
NEW_ITEM_SCORE=0 NEW_ITEM_SCORE=0
case "$DIFFICULTY_SCORE" in case "$DIFFICULTY_SCORE" in
[123]) NEW_ITEM_SCORE=0 ;; #HARD DIFFICULTY & NORMAL [123]) NEW_ITEM_SCORE=0 ;;#HARD DIFFICULTY & NORMAL
4) NEW_ITEM_SCORE=1 ;; #MILD 4) NEW_ITEM_SCORE=1 ;;#MILD
5) NEW_ITEM_SCORE=2 ;; #EASY 5) NEW_ITEM_SCORE=2 ;;#EASY
*) NEW_ITEM_SCORE=0 ;; #INVALID *) NEW_ITEM_SCORE=0 ;;#INVALID
esac esac
elif [ "${q[3]}" = 1 ]; then elif [ "${q[3]}" = 1 ]; then
case "$DIFFICULTY_SCORE" in case "$DIFFICULTY_SCORE" in
1) NEW_ITEM_SCORE=0 ;; #HARD 1) NEW_ITEM_SCORE=0 ;;#HARD
2) NEW_ITEM_SCORE=0 ;; #DIFFICULT 2) NEW_ITEM_SCORE=0 ;;#DIFFICULT
3) NEW_ITEM_SCORE=1 ;; #NORMAL 3) NEW_ITEM_SCORE=1 ;;#NORMAL
4) NEW_ITEM_SCORE=2 ;; #MILD 4) NEW_ITEM_SCORE=2 ;;#MILD
5) NEW_ITEM_SCORE=3 ;; #EASY 5) NEW_ITEM_SCORE=3 ;;#EASY
*) NEW_ITEM_SCORE=1 ;; #INVALID *) NEW_ITEM_SCORE=1 ;;#INVALID
esac esac
else else
case "$DIFFICULTY_SCORE" in case "$DIFFICULTY_SCORE" in
1) NEW_ITEM_SCORE="$((q[3] - 2))" ;; #HARD 1) NEW_ITEM_SCORE="$((${q[3]}-2))" ;;#HARD
2) NEW_ITEM_SCORE="$((q[3] - 1))" ;; #DIFFICULTY 2) NEW_ITEM_SCORE="$((${q[3]}-1))" ;;#DIFFICULTY
3) NEW_ITEM_SCORE="${q[3]}" ;; #NORMAL 3) NEW_ITEM_SCORE="${q[3]}" ;;#NORMAL
4) NEW_ITEM_SCORE="$((q[3] + 1))" ;; #MILD 4) NEW_ITEM_SCORE="$((${q[3]}+1))" ;;#MILD
5) NEW_ITEM_SCORE="$((q[3] + 2))" ;; #EASY 5) NEW_ITEM_SCORE="$((${q[3]}+2))" ;;#EASY
*) NEW_ITEM_SCORE="${q[3]}" ;; #INVALID *) NEW_ITEM_SCORE="${q[3]}" ;;#INVALID
esac esac
fi fi
# Update item score for each flashcard item # Update item score for each flashcard item
## Remove forward slashes in the Questions and answers sed -i "s/${q[0]}:${q[1]}:${q[2]}:${q[3]}/${q[0]}:${q[1]}:${q[2]}:$NEW_ITEM_SCORE/g" "$DECK"
QUESTION_REGEX="$(sed "s/\(\/\|\[\|\]\|\*\)/\\\\\1/g" <<<"${q[1]}")"
ANSWER_REGEX="$(sed "s/\(\/\|\[\|\]\|\*\)/\\\\\1/g" <<<"${q[2]}")"
sed -i "s/${q[0]}:$QUESTION_REGEX:$ANSWER_REGEX:${q[3]}/${q[0]}:$QUESTION_REGEX:$ANSWER_REGEX:$NEW_ITEM_SCORE/g" "$DECK"
# If no highscore currently set, set it.
[ -z "$(cat "$HIGH_SCORE")" ] && echo "$COUNTER" >"$HIGH_SCORE"
# If Cards Reviewed > Current High Score, Update
[ "$COUNTER" -gt "$(cat "$HIGH_SCORE")" ] && echo "$COUNTER" >"$HIGH_SCORE"
} }
while true; do while true; do

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 702 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 35 KiB