dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 38b51e3fec13897c5b462c591032a2294afca53c
parent 67896ca659b9b293418bc5bdda9a039b7c06b287
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Fri,  7 May 2021 17:05:32 +0200

Unify file viewing in mutt

Diffstat:
Mmailcap | 20+++++++++++++++-----
Mscripts/linkhandler | 1+
Mscripts/open | 2++
Mscripts/opener | 3+++
4 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/mailcap b/mailcap @@ -1,7 +1,17 @@ -image/*; sh -c 'case "%s" in http*) name="/tmp/$(printf "%s" | sed "s/.*\///")"; curl -sL "%s" > "$name";; *) name="%s";; esac; sxiv -a "$name"' -video/*; mpvq %s +# Mailcap: mainly used for viewing attachments in (Neo)Mutt +# So that HTML can render automatically in email text/html; w3m -config /Users/alex/.config/w3m/config -T text/html %s; copiousoutput -text/plain; less -application/pdf; setsid -f zathura %s -application/vnd.openxmlformats-officedocument.wordprocessingml.document; open -a 'Microsoft Word' %s + +# Need a pager that doesn't quit automatically for plaintext +text/plain; LESS="-Ric" less + +# Preview contents of tgz files application/x-tar-gz; tar tzf %s | less -R + +# Open pgp signatures as text +application/pgp-signature; LESS="-Ric" less + +# Use the `opener` script for everything else +image; setsid -f opener %s >/dev/null 2>&1 +video; setsid -f opener %s >/dev/null 2>&1 +application; setsid -f opener %s >/dev/null 2>&1 diff --git a/scripts/linkhandler b/scripts/linkhandler @@ -1,4 +1,5 @@ #!/bin/sh +# Linkhandler: handles links. Like `opener` but for URLs [ -z "$1" ] && { "$BROWSER"; exit; } case "$1" in diff --git a/scripts/open b/scripts/open @@ -1,4 +1,6 @@ #!/bin/sh +# A wrapper around xdg-open and macOS's open + PARAMS="" while [ $(($#)) -ne 0 ]; do case "$1" in diff --git a/scripts/opener b/scripts/opener @@ -1,6 +1,9 @@ #!/bin/sh +# Opener: given a local file, decide which program to use to open it + [ $# -gt 0 ] || { printf "File required in argument.\n" && exit 1; } case "$1" in + # Handling links is another script's job http*) linkhandler "$@";; *) case $(file --mime-type "$1" -bL) in