Fork me on GitHub

article

View man files as PDF

January 18, 2011 | Computers

Sometimes viewing man pages on the command line is less than convenient. Ok, its always inconvenient. But there’s a better way: convert the man page to pdf and view it with Preview.

Add this to a file, I named mine manv, put it in a safe place (I keep a /bin folder in my home directory) and make it executable with chmod a+x filename.

  1.  #! /bin/bash
  2.  if [ "$#" = "1" ]; then
  3.   man -t ${1} > /tmp/${1}.ps
  4.   pstopdf /tmp/${1}.ps /tmp/${1}.pdf
  5.   open -a Preview.app /tmp/${1}.pdf
  6.   sleep 10
  7.   rm /tmp/${1}.ps /tmp/${1}.pdf
  8.  fi

Now invoke the man page with your new script name instead of with man and read it in Preview. Enjoy!

One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Mentions

  1. Around the web | alexking.org

    […] View man files as PDF – handy! […]

    January 23, 2011 | 5:12 pm

Comments are closed