slide deck presentation tool written in pure bash

add slide number indicator

Akshay 1b9f2233 e1b8a8a5

Changed files
+13 -4
+13 -4
shlide
··· 30 30 display() { 31 31 # 1 - slide contents 32 32 # 2 - slide name 33 + # 3 - current slide nr. 34 + # 4 - total nr. of slides 33 35 34 36 slide_contents="$1" 35 37 ··· 39 41 # Clear the screen. 40 42 printf '\e[2J' 41 43 42 - # Move the cursor to the center. 43 - read -r LINES COLUMNS < <(stty -F /dev/tty size) 44 + # Get screen size 45 + shopt -s checkwinsize; (:;:) 46 + 47 + # Write slide number at bottom left 48 + printf '\e[H' 49 + printf '\e[%sB%s/%s' "$LINES" "$(($3+1))" "$4" 50 + 51 + # Custom calculations to center text 44 52 height=$(lines "$2") 45 53 width=$(longest_line "$2") 46 54 ··· 80 88 slides=("$slides_dir"/[0-9]*.txt) 81 89 i=0 82 90 while true; do 83 - 91 + # Clear the screen. 92 + printf '\e[2J' 84 93 # Display END reached prompt, and then exit 85 94 [[ "$i" -eq "${#slides[@]}" ]] && { 86 95 display_end ··· 101 110 [[ "$i" -lt 0 ]] && i=0 102 111 103 112 # Navigate on j/k/n/p and quit on q. 104 - display "$(<${slides[$i]})" "${slides[$i]}" 113 + display "$(<${slides[$i]})" "${slides[$i]}" "$i" "${#slides[@]}" 105 114 read -rsn1 input 106 115 case "$input" in 107 116 "j"|"n")