diff --git a/quotes.sh b/quotes.sh index 7e5dfc7..5af5ecb 100755 --- a/quotes.sh +++ b/quotes.sh @@ -5,6 +5,7 @@ usage() { usage $0 [-d|r][-f][-h] -d, --daily get the QOTD -r, --random get a random quote + -p, --pager use pager to prevent quitting until keypress -f, --force force update the quote pool -h, --help display this message EOF @@ -60,13 +61,14 @@ for arg in "$@"; do '--help') set -- "$@" '-h' ;; '--random') set -- "$@" '-r' ;; '--daily') set -- "$@" '-d' ;; + '--pager') set -- "$@" '-p' ;; '--force') set -- "$@" '-f' ;; *) set -- "$@" "$arg" ;; esac done # parse args -while getopts "hrdf" opt ; do +while getopts "hrdfp" opt ; do case "$opt" in 'h') usage @@ -81,6 +83,9 @@ while getopts "hrdf" opt ; do 'f') UPDATE=true ;; + 'p') + PAGE=true + ;; '?') usage exit 1 @@ -93,4 +98,8 @@ QUOTE=$(get_quote "$TYPE") Q=$(echo "$QUOTE" | gojq '.q' | tr -d '"') A=$(echo "$QUOTE" | gojq '.a' | tr -d '"') -printf '"%s" - %s\n' "$Q" "$A" +if [ -n "$PAGE" ] ; then + printf '"%s" - %s\n' "$Q" "$A" | $PAGER +else + printf '"%s" - %s\n' "$Q" "$A" +fi