all repos — shlide @ 1f1d678528d8455c47a070d0162bd8ef7c220c1a

slide deck presentation tool written in pure bash

Init

Signed-off-by: Anirudh Oppiliappan <x@icyphox.sh>
Anirudh Oppiliappan x@icyphox.sh
Sun, 02 Feb 2020 15:19:30 +0530
commit

1f1d678528d8455c47a070d0162bd8ef7c220c1a

6 files changed, 111 insertions(+), 0 deletions(-)

jump to
A Makefile

@@ -0,0 +1,7 @@

+PREFIX ?= /usr + +install: + install -Dm755 pw $(DESTDIR)$(PREFIX)/bin/shlide + +uninstall: + rm -f $(DESTDIR)$(PREFIX)/bin/shlide
A example/1-hi.txt

@@ -0,0 +1,8 @@

+HI THERE + +Welcome to shlide. Here are a few bullet points: + +- first point +- second point + * sub point + * another sub point
A example/2-another.txt

@@ -0,0 +1,7 @@

+THIS IS ANOTHER SLIDE + +We've got some more info here! + +- like this point +- and this one +- the last one, I promise
A example/3-bye.txt

@@ -0,0 +1,3 @@

+THAT'S IT, BYE! + +And we're done.
A readme.md

@@ -0,0 +1,5 @@

+# shlide +> a slide deck presentation tool written in pure bash + +![scrot](https://x.icyphox.sh/NBq.png) +
A shlide

@@ -0,0 +1,81 @@

+#!/usr/bin/env bash +# +# Usage: shlide path/to/slides/ +# Each slide is a textfile under path/to/slides + +# Color definitions + +#BLK="\e[30m" +#RED="\e[31m" +#GRN="\e[32m" +#YLW="\e[33m" +#BLU="\e[34m" +#PUR="\e[35m" +#CYN="\e[36m" + +lstrip() { + # See: https://github.com/dylanaraps/pure-bash-bible#strip-pattern-from-start-of-string + printf '%s\n' "${1##$2}" +} + +get_term_size() { + + # POSIX alternative to 'checkwinsize'. + read -r LINES COLUMNS < <(stty -F /dev/tty size) + +} + +# navigate() { +# case "$1" in +# "j") +# } + +display() { + # 1 - slide contents + # 2 - slide name + + slide_contents="$1" + # slide_name="$(lstrip $2 "[0-9]-")" + + # Hides the cursor. + printf '\e[?25l' + + # Clear the screen. + printf '\e[2J' + + # Move the cursor to the center. + get_term_size + + # Rough estimates for the true center. + ((l=0)) + ((c=0)) + printf '\e[%s;%sH' "$l" "$c" + + while IFS= read -r line; do + # Print the contents of the slide file, + # line by line. + printf '%s' "$line" + # 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" + done + + # Return the cursor. + printf '\e[?25h' + +} + +main "$@"