slide deck presentation tool written in pure bash

Better comments, trap Ctrl+C

Signed-off-by: Anirudh Oppiliappan <x@icyphox.sh>

Changed files
+16 -7
+16 -7
shlide
··· 28 28 } 29 29 30 30 colorify() { 31 + # 'eval' hack to achieve substitution for colors. 31 32 eval "declare dummy=\"$1\"" 32 33 printf '%b' "$dummy" 33 34 } 34 35 36 + # Filter out color sequences. 35 37 shopt -s extglob 36 38 ansi_filter() { 37 - local IFS= 38 - echo "${1//$'\e'[\[(]*([0-9;])[@-n]/}" 39 - #/" a little fix to keep my vim syntax hl sane 39 + local IFS= 40 + echo "${1//$'\e'[\[(]*([0-9;])[@-n]/}" 41 + #" A little fix to prevent vim syntax highlighting from breaking. 40 42 } 41 43 42 44 ··· 88 90 89 91 } 90 92 93 + die() { 94 + printf '\e[?25h' 95 + exit 0 96 + } 97 + 91 98 display_end() { 92 99 read -r LINES COLUMNS < <(stty -F /dev/tty size) 93 100 ((l=$LINES/2)) ··· 105 112 while true; do 106 113 # Clear the screen. 107 114 printf '\e[2J' 115 + 116 + # Capture Ctrl+C. 117 + trap 'die' INT 118 + 108 119 # Display END reached prompt, and then exit 109 120 [[ "$i" -eq "${#slides[@]}" ]] && { 110 121 display_end ··· 112 123 case "$input" in 113 124 "j"|"n"|"q") 114 125 printf '\e[2J' 115 - printf '\e[?25h' 116 - exit 126 + die 117 127 ;; 118 128 *) 119 129 ((--i)) ··· 136 146 ;; 137 147 "q") 138 148 # Return the cursor on exit. 139 - printf '\e[?25h' 140 - exit 149 + die 141 150 ;; 142 151 esac 143 152 done