OS X: Create a Command to View UNIX “man” Pages as PDFs

A website tipped me off to a Terminal command that lets OS X users (the geekier ones) view UNIX “man” pages* as PDFs.

However, since the command is long, it would be hard to remember and difficult to type. I wanted to make an alias (a custom UNIX command) that would be shorter, but Bash (the default terminal in OS X) does not allow aliases to accept arguments (variables), which is critical to making this work.

I found a way to create a custom command that does this. Here are the steps:

  1. Edit your ~/.bash_profile with your favorite text editor
  2. Add this line:
    [cc]manpdf () { man -t $1 | open -f -a Preview.app ; }[/cc]
    (You could call it something other than “manpdf” if you want; you may also want to add a comment to remind yourself what it does.)
  3. Save it
  4. Try it: Open Terminal and type:
    [cc]manpdf ping[/cc]

Enjoy!

*For newbies: The “man” command lists instructions — “manuals” — for various UNIX commands. For example, if you wanted to know how to use the “ping” command, you could open Terminal and type “man ping”.

Published by Michael Prewitt

Michael Prewitt is a creative director who has in graphic design since 1992. While his primary work is design and layout, he also has skills in writing and editing, web developing, front-end and macro-type programming, photography, photo retouching and compositing, and branding.

Leave a comment

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.