+4
readme.md
+4
readme.md
+14
-10
shlide
+14
-10
shlide
···
1
1
#!/usr/bin/env bash
2
-
#
3
-
# Usage: shlide path/to/slides/
4
-
# Each slide is a textfile under path/to/slides
2
+
# shellcheck disable=2154
3
+
#
4
+
# shlide - a slide deck presentation tool written in pure bash
5
+
# https://github.com/icyphox/shlide
6
+
#
7
+
# The MIT License (MIT)
8
+
#
9
+
# Copyright (c) 2020 Anirudh Oppiliappan <x@icyphox.sh>
5
10
6
11
# Color definitions.
7
12
export BLK="\e[38;5;30m"
···
62
67
63
68
slide_contents="$1"
64
69
65
-
# Hides the cursor.
70
+
# Hide the cursor.
66
71
printf '\e[?25l'
67
72
68
73
# Clear the screen.
69
74
printf '\e[2J'
70
75
71
-
# Get screen size
72
-
shopt -s checkwinsize; (:;:)
76
+
# Get screen size.
77
+
read -r LINES COLUMNS < <(stty -F /dev/tty size)
73
78
74
-
# Write slide number at bottom left
79
+
# Write slide number at bottom left.
75
80
printf '\e[H'
76
81
printf '\e[%sB%s/%s' "$LINES" "$(($3+1))" "$4"
77
82
78
-
# Custom calculations to center text
83
+
# Custom calculations to center text.
79
84
height=$(lines "$2")
80
85
width=$(longest_line "$2")
81
86
···
109
114
}
110
115
111
116
display_end() {
112
-
read -r LINES COLUMNS < <(stty -F /dev/tty size)
113
117
((l=LINES/2))
114
118
((c=COLUMNS/2 - 8))
115
119
printf '\e[2J'
···
129
133
# Capture Ctrl+C.
130
134
trap 'die' INT
131
135
132
-
# Display END reached prompt, and then exit
136
+
# Display END reached prompt, and then exit.
133
137
[[ "$i" -eq "${#slides[@]}" ]] && {
134
138
display_end
135
139
read -rsn1 input