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 61c114cca363c4b0c39b0c4d9aadbf4cff0e21cf
parent 473078b0c709d200992bab8e70e0ab2cf465c428
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Tue, 31 Mar 2020 11:28:02 +0200

Open plaintext with $PAGER, open terminal applications in current terminal if open

Diffstat:
M.local/bin/plumb | 17++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/.local/bin/plumb b/.local/bin/plumb @@ -39,6 +39,14 @@ regeximatch() { printf '%s' "$1" | grep -i -E -q "$2" } +termopen() { + if [ -z "$TERM" ]; then + detach $TERMINAL "$@" + else + "$@" + fi +} + fetch() { _o="$(mktemp)" if type -v hurl >/dev/null 2>&1; then @@ -107,7 +115,7 @@ handle_target() { elif regexmatch "$t" '10\.[0-9]*\/'; then detach $BROWSER "https://doi.org/${t}" elif regexmatch "$t" '\.(txt|patch|diff|rst|md)$'; then - detach $TERMINAL less "$(fetch "$t")" + termopen less "$(fetch "$t")" 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 @@ -120,13 +128,8 @@ handle_target() { port="$(printf '%s' "$t" | awk -F'\t' '{print $4}')" t="${host}:${port}/${type}${path}" fi - echo "$t" + termopen sacc "$t" - if [ -z "$TERM" ]; then - detach $TERMINAL sacc "$t" - else - sacc "$t" - fi elif regexmatch "$t" '\.[0-9]$'; then if [ -z "$TERM" ]; then detach $TERMINAL mandoc -l "$(fetch "$t")"