dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit f45c40c36ed3469f5e712b333821c44c325e8ea5
parent 0dee2d7b5778ed51558624c2665a332297e4634a
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Tue,  5 May 2020 15:32:32 +0200

Increase priority of gopher format strings

Diffstat:
M.local/bin/plumb | 28+++++++++++++---------------
M.local/bin/search | 2--
2 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/.local/bin/plumb b/.local/bin/plumb @@ -174,6 +174,16 @@ handle_target() { t="${t}tc-${v}-${n}-${y}.pdf";; esac + if regexmatch "$t" '^(0|1|3|7|9|g|I|h)' && \ + [ "$(printf '%s' "$t" | awk -F'\t' '{print NF}')" -eq 4 ]; then + # construct uri from gopher item + type="$(printf '%s' "$t" | cut -c 1)" + path="$(printf '%s' "$t" | awk -F'\t' '{print $2}')" + host="$(printf '%s' "$t" | awk -F'\t' '{print $3}')" + port="$(printf '%s' "$t" | awk -F'\t' '{print $4}')" + t="gopher://${host}:${port}/${type}${path}" + fi + if regeximatch "$t" '\.(mp4|mkv|webm|avi|ogv|gifv)$'; then detach mpv "$(fetch "$t")" elif regeximatch "$t" '^radio://'; then @@ -184,8 +194,6 @@ handle_target() { sxiv "$(fetch "$t")" elif regeximatch "$t" '\.(pdf|ps|epub|djvu)$'; then zathura "$(fetch "$t")" - elif regeximatch "$t" '(youtube\.|youtu\.be|vimeo\.com)'; then - cd ~/tmp && detach mpv "$t" elif regeximatch "$t" '(smbc-comics\.com|xkcd\.com|jspowerhour\.com)'; then cd /tmp && detach comic "$t" elif regexmatch "$t" '10\.[0-9]*\/'; then @@ -193,30 +201,20 @@ handle_target() { elif regexmatch "$t" '\.(txt|patch|diff|rst|md)$'; then f="$(fetch "$t")" termopen less "$f" - elif regeximatch "$t" '^gopher://' || \ - { regexmatch "$t" '^(0|1|3|7|9|g|I|h)' && \ - [ "$(printf '%s' "$t" | awk -F'\t' '{print NF}')" -eq 4 ]; }; then - - if [ "$(printf '%s' "$t" | awk -F'\t' '{print NF}')" -eq 4 ]; then - # construct uri from gopher item - type="$(printf '%s' "$t" | cut -c 1)" - path="$(printf '%s' "$t" | awk -F'\t' '{print $2}')" - host="$(printf '%s' "$t" | awk -F'\t' '{print $3}')" - port="$(printf '%s' "$t" | awk -F'\t' '{print $4}')" - t="${host}:${port}/${type}${path}" - fi + elif regeximatch "$t" '^gopher://'; then if regeximatch "$t" "\.onion"; then termopen torsocks sacc "$t" else termopen sacc "$t" fi - elif regexmatch "$t" '\.[0-9]$'; then if [ -z "$TERM" ]; then detach $TERMINAL mandoc -l "$(fetch "$t")" else mandoc -l "$(fetch "$t")" fi + elif regeximatch "$t" '(youtube\.|youtu\.be|vimeo\.com)'; then + cd ~/tmp && detach mpv "$t" elif regeximatch "$t" '^(http|https)://' || \ regeximatch "$t" '\.webp$'; then detach $BROWSER "$t" diff --git a/.local/bin/search b/.local/bin/search @@ -26,11 +26,9 @@ regeximatch() { printf '%s' "$1" | grep -i -E -q "$2" } - if regeximatch "$c" '^gopher://' || \ { regexmatch "$c" '^(0|1|3|7|9|g|I|h)' && \ [ "$(printf '%s' "$c" | awk -F'\t' '{print NF}')" -eq 4 ]; }; then - echo "this is gopher" plumb "$c" elif regeximatch "$c" '^(http|https)://'; then