Oh… man

Has this ever happened to you? You’re in the middle of typing a command at the Terminal, and you realize you need to look up an option or some other aspect of the command in its man page. You can’t issue the man command without deleting what you’ve already typed, which might be extensive if you’re putting together a long pipeline. What’ll you do? What will you do?1

For years, I’ve been using my minor fork of Bruji’s Bwana, a man page viewer that works in the browser. I like it, but it does force me to switch contexts out of the Terminal and into Safari. The other day, though, I ran across this page by Russell Harris, explaining a feature of Terminal I never knew existed:

Just right-click (or Control-click) on the command you want to look up. The word will highlight, and the context menu that pops up will have Open man Page as its top item.

Terminal man page context menu

Select that item, and a new terminal window will appear with the man page. Scroll through it to find what you need—or use ⌘F—and close the window when you’re done.

Man page in Terminal

Because this is also a Terminal window, you can right-click on any referenced command (like those in the See Also section) to bring up its man page.

How long has this nice little option been available? This page at Mac OS X Tips says it first appeared in Lion. Siracusa’s Lion review had a short section on new Terminal features, but didn’t mention this.

Terminal’s default profile for man pages uses a font that’s far too small and a yellow background that’s far too bright for my taste. The appearance can be changed by choosing Terminal‣Preferences… (or typing ⌘,) when the man page window is active. The font settings are in the Text pane, and the background color setting is in the Window pane. The changes will apply to the current man page window and to all subsequent man page windows.

Terminal preferences for man pages

I can’t be sure yet, but I think I’ll be using this instead of Bwana from now on. One thing is certain: handy access to man pages is essential when you’re trying out new commands. Don’t leave home without them.

  1. Pro tip: Humorous allusions to Karl Malden commercials from 40 years ago will bring tons of traffic to your blog.