How to change default "reading" program?

Not sure about OSX, but hopefully it's Unix-y enough...

In your $HOME/.bashrc add the following line:

export MANPAGER=cat

If you want all of your paging programs to act in this way, set PAGER instead. man will use MANPAGER if set, otherwise it falls back to PAGER, which if not set falls back to more.


To get the effect you want, where you get a man page in a separate window with the view starting at the first page, add the following to your ~/.bash_profile:

function man {
    mf=`mktemp /tmp/$1-formatted-XXXXXXXXX`
    /usr/bin/man -t "$@" | pstopdf -i -o $mf
    mv $mf $mf.pdf
    open -W $mf.pdf
    rm $mf.pdf
}

You can log out and back in to activate it, or just reload the file with:

. ~/.bash_profile

The latter risks redefining things like the PATH variable with duplicate info.

This function overrides the man command, causing it to build a PDF-formatted version of the man page in a temporary file, open that in your PDF viewer (Preview, by default) and then remove the temporary PDF when you close the viewer. The idea being, your default PDF viewing program probably responds to the touchpad the way you want.

In order to get that last feature, where it removes the temporary PDF, I had to make open(1) wait until the PDF viewer closed before it proceeds. This means you can't continue to use your terminal window while the PDF stays open. One hack around this would be to remove the -W flag and follow the open command with something like sleep 1, which should be enough time for Preview to open. Another hack might be to replace the last line with something like this:

( sleep 60 ; rm $mf.pdf ) &

That schedules the rm command for 60 seconds in the future, certainly enough time.