diff --git a/bin/path-shim b/bin/path-shim index 66fc0b4..405626e 100755 --- a/bin/path-shim +++ b/bin/path-shim @@ -5,6 +5,7 @@ export PATH="/etc/profiles/per-user/$USER/bin:/run/current-system/sw/bin:$PATH" export SOPS_AGE_KEY_FILE="$HOME/.config/sops/age/keys.txt" +export NOTMUCH_CONFIG="$HOME/.config/notmuch/config" if [[ $# -eq 1 ]]; then # Single argument - run it through bash to handle complex commands diff --git a/bin/view-email-html b/bin/view-email-html new file mode 100755 index 0000000..33a8502 --- /dev/null +++ b/bin/view-email-html @@ -0,0 +1,191 @@ +#!/bin/bash +# Convert email to HTML and open in browser with images + +emlfile="/tmp/neomutt-email-$$.eml" +tmpdir="/tmp/neomutt-email-$$" +tmpfile="$tmpdir/email.html" + +# Save email from stdin +mkdir -p "$tmpdir" +cat >"$emlfile" + +# Extract MIME parts using ripmime if available +if command -v ripmime &>/dev/null; then + ripmime -i "$emlfile" -d "$tmpdir" --no-nameless 2>/dev/null +elif command -v munpack &>/dev/null; then + cd "$tmpdir" && munpack -q "$emlfile" 2>/dev/null +fi + +# Check if there's an HTML part extracted +html_part=$(find "$tmpdir" -maxdepth 1 -name "*.html" -o -name "*.htm" 2>/dev/null | head -1) + +if [[ -n $html_part && -s $html_part ]]; then + # Use extracted HTML directly + cp "$html_part" "$tmpfile" +else + # Generate HTML from text + { + echo "
" + echo '' + echo "" + echo "" + echo '' + echo "" + + # Extract and display headers (handles multi-line headers) + echo '" header ":
" header ": " value "
" + } + } else { + print "" header ": " value "
" + } + } + header = ""; value = "" + } + /^$/{output(); exit} + /^(From|To|CC|Bcc|Reply-To|Subject|Date):/{ + output() + show=1 + match($0, /^[^:]+/) + header = substr($0, 1, RLENGTH) + value = substr($0, RLENGTH+2) + gsub(/^[ \t]+|[ \t]+$/, "", value) + next + } + /^[A-Za-z0-9-]+:/ && !/^(From|To|CC|Bcc|Reply-To|Subject|Date):/{output(); show=0} + show && /^[ \t]/{ + gsub(/^[ \t]+/, "", $0) + value = value " " $0 + } + END{output()}' "$emlfile" + echo ""; incode=1 }
+ next
+ }
+ {
+ gsub(/, "\\<")
+ gsub(/>/, "\\>")
+ if (!incode) {
+ # Handle inline code `code`
+ while (match($0, /`[^`]+`/)) {
+ before = substr($0, 1, RSTART-1)
+ code = substr($0, RSTART+1, RLENGTH-2)
+ after = substr($0, RSTART+RLENGTH)
+ $0 = before "" code "" after
+ }
+ }
+ print
+ }
+ END { if (incode) print "" }
+ '
+ echo "