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 78b32c7c439a7affe05d718735465f78e75427aa
parent d5f306ec0a06ef7d136955ff2d6d1e0df71ee789
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Thu, 25 Apr 2019 11:23:28 +0200

Update nnn, handle printing of emails with long subject strings, newline after ---*

Diffstat:
M.mutt/muttprint-groff.sh | 31+++++++++++++------------------
1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/.mutt/muttprint-groff.sh b/.mutt/muttprint-groff.sh @@ -1,15 +1,8 @@ -#!/bin/bash +#!/bin/sh PDIR="$HOME/tmp/mutt_print" -OPEN_PDF=zathura -# create temp dir if it does not exist -if [ ! -d "$PDIR" ]; then - if ! mkdir -p "$PDIR" 2>/dev/null; then - echo "Unable to make directory '$PDIR'" 1>&2 - exit 2 - fi -fi +mkdir -p "$PDIR" 2>/dev/null infile="$(mktemp "$PDIR"/mutt_XXXXXXXX.txt)" tmpfile="$(mktemp "$PDIR"/mutt_XXXXXXXX.roff)" @@ -19,10 +12,10 @@ echo "infile = $infile" echo "tmpfile = $tmpfile" echo "outfile = $outfile" -while read -r line -do - echo "$line" >> "$infile" -done < "${1:-/dev/stdin}" +cat "${1:--}" > "$infile" + +# join lines starting with space with previous line +sed -i '$!N;s/\n //;P;D' "$infile" echo "formatting $infile to groff format in $tmpfile" mail_date="$(grep '^Date: ' "$infile")" @@ -39,17 +32,19 @@ mail_subject="$(grep '^Subject: ' "$infile")" printf ".AI\n%s\n" "$mail_date"; printf ".LP\n"; grep -v "^Date:\|^From:\|^To:\|^Subject:\|^Cc:\|^X-Mailer:\|^User-Agent:" "$infile" | \ - sed 's/^>//;s/^ //' | cat --squeeze-blank | \ + sed 's/^>*//;s/^ //' | \ sed 's/\(Fra\|Dato\|Til\|Emne\): /\n\1: /g' | \ sed 's/\(From\|Date\|To\|Cc\|Subject\): /\n\1: /g' | \ - sed '/^Links:$/Q'; + sed 's/^\[\([0-9]\)\] /\n[\1]: /g' | \ + sed '/^Links:$/Q' | \ + sed 's/\([-]*\)/\1\n/' | \ + cat --squeeze-blank; } \ > "$tmpfile" echo "running groff $tmpfile $outfile" preconv "$tmpfile" | groff -ms -T pdf > "$outfile" -read -r -$OPEN_PDF "$outfile" >/dev/null 2>&1 & +xdg-open "$outfile" & sleep 1 -rm "$infile" "$tmpfile" "$outfile" +#rm "$infile" "$tmpfile" "$outfile"