# Finding man pages on the web with TextExpander 4

You know by now that TextExpander 4 is out and that its fill-ins feature comes with more options: default values, multiline text fields, optional sections, and popup menus. You can read about them on Smile’s site or see them in action in David Sparks’s screencast. I haven’t started digging too deeply into the new stuff, but the popup menu did inspire me to write a snippet I’ve been meaning to make for a while.

I often write about Unix commands here, and when I do, I usually link to the command’s man page on Apple’s site so readers can learn more about the command than what I cover. That means I first have to find the page myself. The best way to do that, I’ve found, is to use a specific set of Google search terms. For example, if I want to go to the man page for pbcopy, I’d type

pbcopy name synopsis site:developer.apple.com


into Safari’s search field (or the omnibar if you’re reading this after Mountain Lion comes out and Safari no longer has a dedicated search field). Since everything except “pbcopy” is boilerplate, this is a perfect candidate for a TextExpander snippet, with the name of the command as the fill-in.

But I can do better. Since the Linux versions of some commands are quite different from the Mac versions,1 and I’ll sometimes want to point out those differences, it’d be nice to be able to search for a man page on linuxmanpages.com, too.

Before TextExpander 4, I’d have to write two snippets, one for each site, but with the new popup menu feature, I can put both types of search into a single snippet.

The content of the snippet is

%filltext:name=command:default=sort:width=20% name synopsis site:%fillpopup:name=site:default=developer.apple.com:linuxmanpages.com%


where the first chunk between the percent signs defines the fill-in for the name of the command,

and the second defines the popup menu for choosing the site to search,

Since I write mostly about commands on OS X, I made the Apple site the default in the popup. The abbreviation is ;man, following my standard format for abbreviations.

Like most TextExpander snippets, this wasn’t hard to make, but it is a timesaver.

1. The Linux versions come from the GNU project and the Mac versions are derived from BSD