clear &&echo -e "You are searching ${CANTICLE^}${CANTO_NUM}.\nAdd a trailing slash ${GREEN}\`/\`${NC} to your search before submitting it. The default first two search choices are ${GREEN}\`canto\`${NC} and then ${GREEN}\`terzine\`${NC}. Press ${GREEN}<enter>${NC} for those defaults and type something else to search that.\n"
clear &&echo -e "You are searching ${canticle^}${CANTO_NUM}.\nAdd a trailing slash ${GREEN}\`/\`${NC} to your search before submitting it. The default first two search choices are ${GREEN}\`canto\`${NC} and then ${GREEN}\`terzine\`${NC}. Press ${GREEN}<enter>${NC} for those defaults and type something else to search that.\n"
read -p "Load previous: (Y)/n " PREV
read -p "Load previous: (Y)/n " PREV
case"$PREV" in
case"$PREV" in
N|n)
N|n)
@ -52,13 +54,13 @@ if [[ -e "$file" ]]; then
if[["${nsearch: -1}"== / ]];then# if last char trailing slash then search
if[["${nsearch: -1}"== / ]];then# if last char trailing slash then search
path="${nsearch::-1}"# remove trailing slash
path="${nsearch::-1}"# remove trailing slash
echo"$path" > .prev-xpath.tmp # store query for next time
echo"$path" > .prev-xpath.tmp # store query for next time
# perform the search (requires `xmllint` and `batcat` pager)
# perform the search (requires `xmlstarlet` and `bat` pager)
xmllint --xpath"$path"$file| batcat -l xml
xmlstarlet sel -t -v"$path"$file| batcat -l xml
exit
exit
elif[["$i"==0]]&&[["$nsearch"=='']];then# load '/canto' query on first loop
elif[["$i"==0]]&&[["$nsearch"=='']];then# load '/TEI/text' query on first loop
search="/canto"
search="_:TEI/_:text/_:"
elif[["$nsearch"=='/canto']];then# load '/canto/terzine' on second loop
elif[["$nsearch"=='_:TEI/_:text/_:']];then# load '/TEI/text/canto/tercets' on second loop