dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

commit 00e52be704e4aef5fa812319d8c622120b2dd59d
parent 094b6b0f22fa89696f7084eecbcd7df1baf0422b
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Tue,  3 Jul 2018 20:26:07 -0400

Improve terminal my-open. Utilize in mailcap.

Diffstat:
M.local/bin/my-open | 20+++++++++++++++++---
M.mailcap | 4++--
2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/.local/bin/my-open b/.local/bin/my-open @@ -22,7 +22,7 @@ then # # $configname # -# format: [mimetype]:default fallback1 fallback2 ... +# format: [mimetype]:default fallback1 fallback2 ...:commandline # second segment of mimetype can be a wildcard. my-open looks for exact # matches first. EOF @@ -44,17 +44,30 @@ EOF then mimecmd=`printf "$mimecmd" "$1"` mimetype=`$mimecmd` + elif echo "$1" | grep -E '^http:\/\/' > /dev/null 2>&1 + then + mimetype='x-scheme-handler/http' + elif echo "$1" | grep -E '^https:\/\/' > /dev/null 2>&1 + then + mimetype='x-scheme-handler/https' + elif echo "$1" | grep -E '^ftp:\/\/' > /dev/null 2>&1 + then + mimetype='x-scheme-handler/ftp' else - mimetype='text/html' + mimetype='application/octet-stream' fi handlers=`cat $configfile | grep -Ev '^#' | grep $mimetype | \ cut -d ':' -f 2` + cmdline=`cat $configfile | grep -Ev '^#' | grep $mimetype | \ + cut -d ':' -f 3` if [ -z "$handlers" ] then mimetype="`echo $mimetype | cut -d '/' -f 1`/*" handlers=`cat $configfile | grep -Ev '^#' | grep $mimetype | \ cut -d ':' -f 2` + cmdline=`cat $configfile | grep -Ev '^#' | grep $mimetype | \ + cut -d ':' -f 3` fi if [ -z "$handlers" ] then @@ -76,7 +89,8 @@ EOF echo "my-open: No handler found in \$PATH" >&2 exit 8 fi - exec $handler $@ + set -- `printf -- "$cmdline" "$1"` + exec $handler "$@" fi # Find handler, if one is available diff --git a/.mailcap b/.mailcap @@ -1,5 +1,5 @@ -text/html; w3m -I %{charset} -T text/html; copiousoutput; -application/pdf; pdftotext '%s' -; copiousoutput; test=test -z "$DISPLAY" +text/html; my-open -T '%s'; copiousoutput; +application/pdf; my-open -T '%s'; copiousoutput; test=test -z "$DISPLAY" application/*; my-open '%s'; needsterminal; test=test -n "$DISPLAY" image/*; my-open '%s'; needsterminal; test=test -n "$DISPLAY" audio/*; my-open '%s'; needsterminal; test=test -n "$DISPLAY"