commit f35db645a2cc9113fcd26cb97a51233e23cbfa60 Author: TUNQRT Date: Wed May 28 13:16:02 2025 +0200 pure bash bible diff --git a/read b/read new file mode 100755 index 0000000..068e898 --- /dev/null +++ b/read @@ -0,0 +1,34 @@ +#!/bin/bash + +message="Valid entries are: -, -,-, , ''" +path=$( readlink -f $0 ) +path=${path%/*} +printf '%s\n' "Chapters:" +for num in {0..19}; do + file="$path/chapter$num.txt" + (( ${#num} == 1 )) && num="0$num" + h=$( grep -m1 . $file ) + h=${h:2} # rm first 2 chars ('# ') +# h="${h#"${h%%[![:space:]]*}"}" # rm leading white spaces + h=${h,,} # all to lowercase + h=${h^} # first to uppercase + printf '%s\n' "$num: $h" +done + +re_num='^[0-9]+$' +while true; do + read -p "Input range: " range + # echo "you chose $range" + start=${range%%-*} + : ${start:=0} + end=${range##*-} + : ${end:=19} + # echo "start is $start and end is $end" + [[ $start =~ $re_num ]] && [[ $end =~ $re_num ]] && break || echo "Not a valid range. $message" +done + +for num in {0..19}; do + file="$path/chapter$num.txt" + (( $num >= $start )) && (( $num <= $end )) && pandoc -s --from=markdown --to=pdf $file | zathura - +# (( $num >= $start )) && (( $num <= $end )) && printf '%s\n' "$file" +done