Preview To The Full

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/

The -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/

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/'

In both of these the -q tells enscript to be quiet, the -p - tells it to accept stdin, the -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 /System/Library/PrivateFrameworks/CorePDF.framework/Versions/A/Resources/FontInfo/.

So 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.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s