From 93f21f4d2b6696af64928c5fd7fbb83d03da8bd5 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 7 Jun 2020 18:43:28 -0500 Subject: Change display and keymaps --- bollux | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/bollux b/bollux index c5e0d95..1489147 100755 --- a/bollux +++ b/bollux @@ -139,7 +139,7 @@ bollux_quit() { } set_title() { - printf '\e]2;%s - bollux\007' "$*" + printf '\e]2;%s\007' "$*" } prompt() { # prompt [-u] PROMPT [READ_ARGS...] @@ -573,19 +573,18 @@ display() { # display METADATA [TITLE] case "$mime" in text/*) - set_title "$BOLLUX_URL" + set_title "$title${title:+ - }bollux" less_cmd=(less -R) mklesskey "$BOLLUX_LESSKEY" && less_cmd+=(-k "$BOLLUX_LESSKEY") less_cmd+=( - -Pm"$title${title:+ - }bollux$" - -PM'o\:open, g\:goto, [\:back, ]\:forward, r\:refresh$' + -Pm"$(less_prompt_escape "$BOLLUX_URL") - bollux$" + -P='o\:open, g\:goto, [\:back, ]\:forward, r\:refresh$' -m - -S ) local typeset local submime="${mime#*/}" - if declare -Fp "typeset_$submime" >/dev/null; then + if declare -Fp "typeset_$submime" &>/dev/null; then typeset="typeset_$submime" else typeset="passthru" @@ -602,6 +601,18 @@ display() { # display METADATA [TITLE] esac } +less_prompt_escape() { + local i + for ((i = 0; i < ${#1}; i++)); do + : "${1:i:1}" + case "$_" in + [\?:\.%\\]) printf '\%s' "$_" ;; + *) printf '%s' "$_" ;; + esac + done + printf '\n' +} + mklesskey() { lesskey -o "$1" - <<-END #command @@ -615,7 +626,8 @@ mklesskey() { \\40 forw-screen-force h left-scroll l right-scroll - ? toggle-option M + ? status # 'status' will show a little help thing. + = noaction END } -- cgit 1.4.1-21-gabe81