#!/usr/bin/env bash # Every few seconds, I show you a string and a fret/note and you play matching note/fret export STRINGS='5-5' export FRETS='0-12' INTERVAL_SECONDS=5 if [ $# == 0 ]; then echo "No options given, use -n for notes or -f for frets" 1>&2 exit 1 fi while getopts 'nf' opt; do case $opt in n) GUESS_NOTES=true;; f) GUESS_FRETS=true;; *) echo "Invalid option, use -n for notes or -f for frets" 1>&2; exit 1 esac done rand_note () { shuf -e Do Do-di Re-be Re Re-di Mi-be Mi Fa Fa-di Sol-be Sol Sol-di La-be La La-di Ti-be Ti -n 1 } clear while true; do printf "String %s; " "$(shuf -i "$STRINGS" -n 1)" test "$GUESS_NOTES" && printf "Fret %s " "$(shuf -i "$FRETS" -n 1)" test "$GUESS_FRETS" && printf "%s " "$(rand_note)" sleep "$INTERVAL_SECONDS" clear done