all repos — shlide @ 1f3b3b500c587215cc0b0175eafd26df0399da0e

slide deck presentation tool written in pure bash

trim repeated code, nav with backspace
Akshay nerdypepper@tuta.io
Sun, 09 Feb 2020 11:00:51 +0530
commit

1f3b3b500c587215cc0b0175eafd26df0399da0e

parent

a4a20985523ce8fb72e8cdc2e9cc41f326f9f5ba

1 files changed, 12 insertions(+), 19 deletions(-)

jump to
M shlideshlide

@@ -135,31 +135,24 @@

# Capture Ctrl+C. trap 'die' INT + # Don't go below 0. + [[ "$i" -lt 0 ]] && i=0 + # Display END reached prompt, and then exit. - [[ "$i" -eq "$total" ]] && { + if [[ "$i" -eq "$total" ]]; then display_end - read -rsn1 input - case "$input" in - "j"|"n"|"q") - die - ;; - *) - ((i=0)) - ;; - esac - } + else + display "$(<"${slides[$i]}")" "${slides[$i]}" "$i" "$total" + fi - # Don't go below 0. - [[ "$i" -lt 0 ]] && i=0 - - # Navigate on j/k/n/p and quit on q. - display "$(<"${slides[$i]}")" "${slides[$i]}" "$i" "$total" + # Navigation read -rsn1 input - case "$input" in - "j"|"n"|"") + case "$input" in + "j"|"n"|""|";") + [[ "$i" -eq "$total" ]] && die ((++i)) ;; - "k"|"p") + "k"|"p"|""|",") ((--i)) ;; "0")