From c6c1dcb0ecdf00882a63f3284eb82747ad70f99c Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 31 May 2020 10:58:44 -0500 Subject: Add quit message and set title --- bollux | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/bollux b/bollux index 4864e48..e84c8b4 100755 --- a/bollux +++ b/bollux @@ -128,6 +128,15 @@ bollux_config() { : "${C_PRE:=0}" # preformatted text formatting } +bollux_quit() { + log x "Thanks for flying $PRGN" + exit +} + +set_title() { + printf '\e]2;%s - bollux\007' "$*" +} + prompt() { prompt="$1" shift @@ -357,7 +366,7 @@ display() { IFS=$'\n' read -d "" -ra hdr <<<"${1//;/$'\n'}" mime="$(trim "${hdr[0],,}")" - for ((i=1;i<="${#hdr[@]}";i++)); do + for ((i = 1; i <= "${#hdr[@]}"; i++)); do h="$(trim "${hdr[$i]}")" log d "'$h'" case "$h" in @@ -374,6 +383,7 @@ display() { case "$mime" in text/*) + set_title "$BOLLUX_URL" less_cmd=(less -R) { [[ -r "$BOLLUX_LESSKEY" ]] || mklesskey "$BOLLUX_LESSKEY" @@ -392,7 +402,7 @@ display() { iconv -f "${charset^^}" -t "UTF-8" - | tee "$BOLLUX_PAGESRC" | run "typeset_$submime" | - run "${less_cmd[@]}" + run "${less_cmd[@]}" && bollux_quit } || run handle_keypress "$?" else log "cat" @@ -400,7 +410,7 @@ display() { normalize_crlf | iconv -f "${charset^^}" -t "UTF-8" - | tee "$BOLLUX_PAGESRC" | - run "${less_cmd[@]}" + run "${less_cmd[@]}" && bollux_quit } || run handle_keypress "$?" fi ;; @@ -596,6 +606,9 @@ handle_keypress() { select_url() { run mapfile -t < <(extract_links <"$1") select u in "${MAPFILE[@]}"; do + case "$REPLY" in + q) bollux_quit ;; + esac run blastoff "$(gawk '{print $1}' <<<"$u")" && break done