Open any man page in Preview and save as PDF

Sep 27, 2010 - 6 Comments

man page preview

If you’re tired of looking over a man page within the Terminal, you can launch any man page into Preview with the following command:
man -t ipconfig | open -f -a /Applications/Preview.app
This example uses ipconfig, but just replace ‘ipconfig’ with any other man page you’d like to read within Preview and it’ll work the same.

Save the man page as PDF

Once the man page is opened within Preview, you can then use Preview to “Save As” and then create a PDF file of the man page for later viewing. I find myself using this command frequently and then saving the PDF to view on my iPad.

If you’re not from a unix background, a ‘man page’ is nothing more than a manual, and they’re really helpful when you’re trying to sort out syntax of various command line features and utilities.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: Manish Patel in Command Line, Mac OS X, Tips & Tricks

6 Comments

» Comments RSS Feed

  1. CraigMC says:

    Better still to register this as a function that can be called from the command line.

    Add this to the bottom of ~/.profile and you can just type a simple command to open the given man page in Preview:

    #Open Man page in Preview
    pman () {
    man -t “${1}” | open -f -a /Applications/Preview.app
    }

    Note: After editing this file you need to reload it for the new function to work. Either quit/restart terminal, or type source ~/.profile (or . ~/.profile if you want to be geeky) and the command will be registered.

    To call the function, just type pman _function_name
    so
    pman ls
    pman fstab

    etc.

    Enjoy
    CraigMC

    PS got this from commandlinefu.com after some google searching

    • Philip says:

      Actually you have to remove the quotes “” from “${1}”, so that it reads ${1} otherwise the quotes will be taken as part of the argument and you will get – No manual entry for “ls”

  2. Vic says:

    I spend about 50 minutes a day on trains and usually just tinker with my iPad since it’s the WiFi model and can’t access the web. I must say I never thought of this, but what a great way to read manuals on the iPad and put that commute to work since my company pays overtime for work related learning.

    Thanks a bunch.

  3. Barry Kelly says:

    If you really need the things in pdf form, and you have ghostscript (and thus ps2pdf) installed, you can skip the middleman with man -t ipconfig | ps2pdf – ipconfig.pdf

  4. [...] that man pages can also be read on the go by saving them as a PDF and opening them with iBooks app on the iPad or iPhone. stLight.options({ [...]

  5. dm says:

    thanks, good thing!

    but it can be a bit short – without full path to Preview.app
    like this:
    man -t wget | open -f -a Preview

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates