Generate man pages with TextExpander

A neat trick for generating man pages from the Terminal using TextExpander.

Sometimes you want to actually, properly read a man page in comfort rather than in the Terminal. For that, it’s not a bad idea to generate it in Preview but I often forget how to do this (usually some time lapses between instances).

So I came up with this neat little TextExpander snippet that allows you to do it:

  • create a new plaintext snippet in TextExpander and call it “manprev” (or whatever works for you—I remember man + Preview)
  • the body of the snippet is this:

man -t %filltext:name=command% | open -f -a /Applications/Preview.app

  • Go back to theTerminal and type manprev on the Command Line
  • a dialogue box comes up like the one at the top of this entry:
  • type in the command name that you are after and hit enter (to complete the snippet)
  • hit enter again (to send the command in the Terminal) and,
  • hey presto, Preview launches with the relevant man page, all elegant and readable, for you to peruse.

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s