all repos — shlide @ 322f09f2d9e68be32bee65849142834242598fed

slide deck presentation tool written in pure bash

add j/k/n/p navigation
Akshay nerdypepper@tuta.io
Sun, 02 Feb 2020 18:48:46 +0530
commit

322f09f2d9e68be32bee65849142834242598fed

parent

5070555ed93a1d07fd4e01cc32bba597f4bfd63f

1 files changed, 22 insertions(+), 8 deletions(-)

jump to
M shlideshlide

@@ -75,18 +75,32 @@ # Move down and back after each print.

printf '\e[%sD\e[B' "${#line}" done <<< "$slide_contents" - # Change slide on space. - read -rsn1 input - #navigate "$input" } main() { - + slides_dir="${1:-./}" - - for f in "$slides_dir"/[0-9]*.txt; do - f_contents="$(<$f)" - display "$f_contents" "$f" + slides=("$slides_dir"*) + i=0 + while true; do + if [ "$i" -gt "$((${#slides[@]} - 1))" ]; then + printf '\e[?25h' + exit; + fi + display "$(<${slides[$i]})" "${slides[$i]}" + read -rsn1 input + case "$input" in + "j"|"n") + ((++i)) + ;; + "k"|"p") + ((--i)) + ;; + "q") + printf '\e[?25h' + exit + ;; + esac done # Return the cursor.