#!/usr/bin/env bash # Color definitions # RED # BLUE # GREEN # YELLOW get_term_size() { # POSIX alternative to 'checkwinsize'. read -r LINES COLUMNS < <(stty size) } display() { # Hides the cursor. printf '\e[?25l' # Clear the screen. printf '\e[2J' # Move the cursor to the center. get_term_size ((l=$LINES/2)) ((c=$COLUMNS/2)) 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 one row down after each print. printf '\e[B' done <<< "$1" # Change slide on space. read -rsn1 input [[ "$input" = " " ]] && continue } main() { slide_dir="$1" for f in $slide_dir/*.txt; do f_contents="$(<$f)" display "$f_contents" done # Return the cursor. printf '\e[?25h' } main "$@"