about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2020-05-31 10:58:44 -0500
committerCase Duckworth2020-05-31 10:58:44 -0500
commitc6c1dcb0ecdf00882a63f3284eb82747ad70f99c (patch)
tree7b213217c2c66bc828dfc110ba341c50da18f2c1
parentTrim mime and only look at it once (diff)
downloadbollux-c6c1dcb0ecdf00882a63f3284eb82747ad70f99c.tar.gz
bollux-c6c1dcb0ecdf00882a63f3284eb82747ad70f99c.zip
Add quit message and set title
-rwxr-xr-xbollux19
1 files 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() {
128 : "${C_PRE:=0}" # preformatted text formatting 128 : "${C_PRE:=0}" # preformatted text formatting
129} 129}
130 130
131bollux_quit() {
132 log x "Thanks for flying $PRGN"
133 exit
134}
135
136set_title() {
137 printf '\e]2;%s - bollux\007' "$*"
138}
139
131prompt() { 140prompt() {
132 prompt="$1" 141 prompt="$1"
133 shift 142 shift
@@ -357,7 +366,7 @@ display() {
357 IFS=$'\n' read -d "" -ra hdr <<<"${1//;/$'\n'}" 366 IFS=$'\n' read -d "" -ra hdr <<<"${1//;/$'\n'}"
358 367
359 mime="$(trim "${hdr[0],,}")" 368 mime="$(trim "${hdr[0],,}")"
360 for ((i=1;i<="${#hdr[@]}";i++)); do 369 for ((i = 1; i <= "${#hdr[@]}"; i++)); do
361 h="$(trim "${hdr[$i]}")" 370 h="$(trim "${hdr[$i]}")"
362 log d "'$h'" 371 log d "'$h'"
363 case "$h" in 372 case "$h" in
@@ -374,6 +383,7 @@ display() {
374 383
375 case "$mime" in 384 case "$mime" in
376 text/*) 385 text/*)
386 set_title "$BOLLUX_URL"
377 less_cmd=(less -R) 387 less_cmd=(less -R)
378 { 388 {
379 [[ -r "$BOLLUX_LESSKEY" ]] || mklesskey "$BOLLUX_LESSKEY" 389 [[ -r "$BOLLUX_LESSKEY" ]] || mklesskey "$BOLLUX_LESSKEY"
@@ -392,7 +402,7 @@ display() {
392 iconv -f "${charset^^}" -t "UTF-8" - | 402 iconv -f "${charset^^}" -t "UTF-8" - |
393 tee "$BOLLUX_PAGESRC" | 403 tee "$BOLLUX_PAGESRC" |
394 run "typeset_$submime" | 404 run "typeset_$submime" |
395 run "${less_cmd[@]}" 405 run "${less_cmd[@]}" && bollux_quit
396 } || run handle_keypress "$?" 406 } || run handle_keypress "$?"
397 else 407 else
398 log "cat" 408 log "cat"
@@ -400,7 +410,7 @@ display() {
400 normalize_crlf | 410 normalize_crlf |
401 iconv -f "${charset^^}" -t "UTF-8" - | 411 iconv -f "${charset^^}" -t "UTF-8" - |
402 tee "$BOLLUX_PAGESRC" | 412 tee "$BOLLUX_PAGESRC" |
403 run "${less_cmd[@]}" 413 run "${less_cmd[@]}" && bollux_quit
404 } || run handle_keypress "$?" 414 } || run handle_keypress "$?"
405 fi 415 fi
406 ;; 416 ;;
@@ -596,6 +606,9 @@ handle_keypress() {
596select_url() { 606select_url() {
597 run mapfile -t < <(extract_links <"$1") 607 run mapfile -t < <(extract_links <"$1")
598 select u in "${MAPFILE[@]}"; do 608 select u in "${MAPFILE[@]}"; do
609 case "$REPLY" in
610 q) bollux_quit ;;
611 esac
599 run blastoff "$(gawk '{print $1}' <<<"$u")" && break 612 run blastoff "$(gawk '{print $1}' <<<"$u")" && break
600 done </dev/tty 613 done </dev/tty
601} 614}