#!/bin/bash ## print_unicode.sh ## By Amanda Hickman https://gist.github.com/amandabee/cf7faad0a6f2afc485ee ## Using https://github.com/baruchel/txt2pdf to print emails to PDF with unicode support. pdir="$HOME/.neomutt/tmp" open_pdf=qpdfview scriptloc="python3 $HOME/.neomutt/bin/text2pdf.py" # check to make sure that we're looking for txt2pdf in the right place if ! command -v python3 $scriptloc >/dev/null; then echo "Is $scriptloc installed?" exit 1 fi # create temp dir if it does not exist if [ ! -d "$pdir" ]; then mkdir -p "$pdir" 2>/dev/null if [ $? -ne 0 ]; then echo "Unable to make directory '$pdir'" 1>&2 exit 2 fi fi # dump stdin to a tempfile tmptxt="`mktemp $pdir/mutt_XXXXXXX.txt`" cat >> $tmptxt tmpfile="`mktemp $pdir/mutt_XXXXXXXX.pdf`" # Actually write the text into a PDF. $scriptloc --quiet -o $tmpfile $tmptxt $open_pdf $tmpfile >/dev/null 2>&1 & sleep 1 rm $tmpfile rm $tmptxt