From 727800a56a695542033a7597c817260a8e1c6d47 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 8 Mar 2025 19:32:50 +0100 Subject: [PATCH] mutt: Prefer bat to glow for html text display WIP: Try out nvim taskwarrior stuff --- office/.local/bin/render-prettyhtml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/office/.local/bin/render-prettyhtml b/office/.local/bin/render-prettyhtml index 26fd0aa..d6037e2 100755 --- a/office/.local/bin/render-prettyhtml +++ b/office/.local/bin/render-prettyhtml @@ -1,6 +1,17 @@ #!/usr/bin/env bash # render html as markdown and display in glow, supports syntax highlighting -# requires: html2text, glow +# requires: html2text, glow or bat # author: CEUK -perl -0777pe 's/()(.*?)(<\/code>)/\1\2\3\n```\2\n\4\n```\n\5/gs' "$1" | html2text | sed -re 's/^\s+(```(\w+)?)/\1/gm' >/tmp/mutt.md -glow -s ~/.config/glow/email.json /tmp/mutt.md | sed 's/\x1b\[[6-9;]*m//g' +fpath=/tmp/mutt.md + +perl -0777pe 's/()(.*?)(<\/code>)/\1\2\3\n```\2\n\4\n```\n\5/gs' "$1" | html2text | sed -re 's/^\s+(```(\w+)?)/\1/gm' -e 's/\x1b\[[6-9;]*m//g' >"$fpath" + +if command -v bat >/dev/null 2>&1; then + bat "$fpath" +elif command -v glow >/dev/null 2>&1; then + glow -s ~/.config/glow/email.json "$fpath" +else + sed 's/\x1b\[[6-9;]*m//g' <"$fpath" +fi + +rm "$fpath" || exit 1