It’s tax season, this means sending documents to accountants proving you weren’t insider trading. I use mutt because I am firmly stuck in the 90s, so printing things to PDFs that look decent enough and are not plain text is a bit of a mission (it seems).
Rather than ‘| lpr’ which will look crappy (and I want it in PDFs anyway), there’s muttprint, which sounds promising, if we ignore the Perl.. Rather than fight that, I added the Homebrew Formula to @mrtazz’s repo at GitHub.com. Simply “brew tap mrtazz/misc” and “brew install mrtazz/misc/muttprint” to build and install muttprint.
Also required is the tiny package of ghostscript, which again, I install with ‘brew install ghostscript’.
And some ugly perl to prevent
[laptop:~]% muttprint
Can't call method "convert" on an undefined value at /usr/local/bin/muttprint line 1915.
Just do a “perl -MCPAN -e ‘install Text::Iconv’”
Wrong latex… LaTeX is some hateful document typesetting from the 1800s, used by academics and… Unix types. Anyway, as muttprint converts to this in the middle, you need to install it, lest it bomb out with:
Muttprint Version 0.72d -- Error
======================================================================
Line 625: Latex didn't work. There's no DVI file. If you write a
bugreport, please include a mail where printing fails.
I cheated and installed the immense MacTex package, which is only a mere 4gigs… sigh.
Now we’re getting somewhere. Now my test of “muttprint -p - <saved_email | ps2pdf - $HOME/muttprint.pdf” was actually making a PDF!
So rather than just clobbering that file, let’s keep adding -number to it, OSX style, with a script.
#!/bin/sh
PATH=$PATH:/usr/local/texlive/2013/bin/x86_64-darwin/
if ! [ -e "$HOME/Desktop/muttprint.pdf" ]
then
FILE="$HOME/Desktop/muttprint.pdf"
else
count=1
while [ -e "$HOME/Desktop/muttprint-${count}.pdf" ]
do
count=$(( $count + 1 ))
done
FILE="$HOME/Desktop/muttprint-${count}.pdf"
fi
muttprint -p - | ps2pdf - "${FILE}"
And then set it in mutt:
set print_command="prettymuttprint.sh"
set print_split
And now when I print I get PDFs on my desktop…
Configure muttprint to not add a tux:
[laptop:~]% cat ~/.muttprintrc
PENGUIN="off"