all repos — shlide @ 1b9f2233838927582e11c7d682b49756a57b50d2

slide deck presentation tool written in pure bash

add slide number indicator
Akshay nerdypepper@tuta.io
Sun, 02 Feb 2020 23:15:30 +0530
commit

1b9f2233838927582e11c7d682b49756a57b50d2

parent

e1b8a8a5390602dbf416ec04e9bff4fea246c90f

1 files changed, 13 insertions(+), 4 deletions(-)

jump to
M shlideshlide

@@ -30,6 +30,8 @@

display() { # 1 - slide contents # 2 - slide name + # 3 - current slide nr. + # 4 - total nr. of slides slide_contents="$1"

@@ -39,8 +41,14 @@

# Clear the screen. printf '\e[2J' - # Move the cursor to the center. - read -r LINES COLUMNS < <(stty -F /dev/tty size) + # Get screen size + shopt -s checkwinsize; (:;:) + + # Write slide number at bottom left + printf '\e[H' + printf '\e[%sB%s/%s' "$LINES" "$(($3+1))" "$4" + + # Custom calculations to center text height=$(lines "$2") width=$(longest_line "$2")

@@ -80,7 +88,8 @@ slides_dir="${1:-./}"

slides=("$slides_dir"/[0-9]*.txt) i=0 while true; do - + # Clear the screen. + printf '\e[2J' # Display END reached prompt, and then exit [[ "$i" -eq "${#slides[@]}" ]] && { display_end

@@ -101,7 +110,7 @@ # 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]}" + display "$(<${slides[$i]})" "${slides[$i]}" "$i" "${#slides[@]}" read -rsn1 input case "$input" in "j"|"n")