I’ve long used a bash function to allow me to read man pages in Preview
# function to send man page to preview
man -t $* | open -f -a /Applications/Preview.app/
-t sends the output of man through groff and converts it to PostScript so we can then pipe it to Preview which happily displays it.
This doesn’t work well for any other command as you need to do some fiddling to get groff to do the conversion for you. Happily
enscript, which can be installed with Homebrew, is much easier to use than groff. For a single command this function works well.
$* | enscript -q -p - -f Menlo-Regular10 -F Menlo-Bold10 -b "$*|%W|Page $%" | open -f -a /Applications/Preview.app
This even prints the command on the left of the header, the date in the middle and the page number on the right. Long commands might overwrite the date in the middle so you can change the
"$*|%W|Page $%" to
"$*||Page $%" and you won’t have the date in the middle.
If you want to send the output of a pipe to Preview that function won’t work but you can use an alias:
alias ppipe='enscript -q -p - -f Menlo-Regular11 -F Menlo-Bold14 | open -f -a /Applications/Preview.app'
In both of these the
-q tells enscript to be quiet, the
-p - tells it to accept
-f specifies the font to use and the
-F the font for the header. By the way, you can find the exact font names in
preview cat ~/.bash_profile gets your bash profile open in Preview while
cat ~/.bash_profile | grep "alias" | ppipe sends all the lines containing “alias” to Preview.
Of course `manp enscript` will get you more details.