Fork me on GitHub

article

View man files as PDF

January 18, 2011 | Computers | 1 Comment

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!