Apple Mac Everything

If you use Terminal regularly you may find yourself reading the ‘man’, pages frequently. These stand for manual and are the help guides for using the different commands. In Terminal if you type man command, where commands is replaced by the command you are using you can view the help guide. Quickly scrolling and viewing the data within the command can be a bit of a pain. For a very long command with many pages of help, it can be a little slow to view all of the information. To help us in this problem we can use a Terminal command to convert the man page to view in Preview. This is a lot more user friendly and allows you to use the resulting file like any pdf.

To view your man pages to one viewable in preview open up Terminal and type or paste in the following and hit enter. Replace xyz with the command you want to view the man page.
man -t xyz | open -f -a /Applications/Preview.app

For example if we want to view the ssh man page in Preview we type the following:
man -t ssh | open -f -a /Applications/Preview.app

Once Preview has done a bit of post processing you will be presented a 13-page pdf with the contents of the ssh man page. Due to the formatting involved with the man page, the resulting output is easy to read and well laid out. Simply save the file out using the Save As menu option, give it a useful name and you are all done.

A man page converted into a PDF document.

Try it yourself, I have been in the process of converting a lot my regularly used man pages in PDF’s. If you find you use this command regularly you can program it as a function Terminal can use. In Terminal type the following, assuming you have a freshly opened Terminal window in the default user path.

open .bash_profile

In the file that opens in TextEdit enter the following:

manpre () {
man -t $@ | open -f -a /Applications/Preview.app
}

You can change manpre to anything you want, something memorable. Save the file, close TextEdit and Quit and re-launch Terminal. Now every time you type the following into Terminal it will load the command you have just entered and convert the man page into a readable one in Preview.

manpre ssh

If you want to remove the command from Terminal, open up .bash_profile and delete the lines in the file.

Simple and clean. I prefer reading the PDF, Preview, versions of man pages over ones in Terminal as it is faster and I get the search function of Preview, very useful if I have a large man page and want to find something specific. If you have any questions or comments about this command, please leave one using the form below.

If you want to keep up with the latests post from Mac Tricks And Tips I recommend you subscribe to the RSS Feed.

About

I'm James, and I have been a Mac user for years. Over this time I have found loads of tips and tricks which have helped me get the most out of my Mac, so I decided to share them with you all. For more info see my about page.

Suggestions

Do you have a tip you want to share, or do you have a suggestion you want to make for a future tip or trick. Then please head over to the contact page and make your comment known.

Contact

Fancy a chat, you can contact me easily. I will respond to any question you ask. Interested in an advertising partnership, have a cool product you want to promote, then please leave a message.