3

I love using the Terminal's man page viewer. You can right click on anything and open its corresponding man page. Or just run open x-man-page://1/<man page>

However, I'm having trouble getting Terminal to prioritize the right man page over a pre-installed one. Specifically it's the man page for the newer version of rsync installed by homebrew. Running man rsync in a shell shows the correct rsync manpage, from /usr/local/share/man/man1/rsync.1, but using Terminal's manpage viewer shows the man page for the old version of rsync from /usr/share/man/man1/rsync.1.gz.

A very temporary solution is to run Terminal like this:

$ MANPATH=/usr/local/share/man /System/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal

That starts Terminal with MANPATH set and it then looks in the right spot to find the new rsync man page. But setting MANPATH overrides all the other smart ways of finding man paths.

Note that the issue only shows up when there's multiple man pages for the same command. Somehow man rsync knows to prioritize the man page installed by Homebrew in /usr/local/share/man but Terminal prioritizes /usr/share/man/

I tried editing /private/etc/man.conf and to /usr/local/share/man first, but it had no effect. Even commenting out all the /usr/share/man references had no effect.

Any ideas how to get Terminal's x-man-page:// to prioritize the right man page like just running man does? Cheers!

2
  • Try putting export MANPATH=/usr/local/share/man:$MANPATH in your .profile or .bashrc or whatever your shell needs.
    – lhf
    Oct 13, 2021 at 22:45
  • 1
    @lhf The trouble with this solution is that MANPATH is already undefined and this defines it. Defining any MANPATH disables the "smart" man path finding that man already does. With my MANPATH empty it finds manpages is a variety of locations. Running man -w -a "*" will list every man page and doing man -w -a "*" | sed -E "s/\/[^\/]*$/\//g" | sort | uniq reveals that there's 57 uniq man page directories on my system. I want to keep using the "smart" man path finding and not have to enumerate every one (since they often change)
    – Chris
    Nov 19, 2021 at 23:48

1 Answer 1

2

I was wondering this too. I couldn't find a direct solution that was better than your workaround of setting MANPATH before launching Terminal.app.

An alternative workaround is to use man, as that's giving you the correct page, and the open command to view the man pages in TextEdit instead of Terminal's view. This can be wrapped in a function (and set in ~/.bashrc) for easy access, e.g.:

mano() { MANWIDTH=100 MANPAGER='col -bx' man "$@" | open -f; }

# use with e.g.
mano rsync

Depending on your default settings in TextEdit, this can give a nice view, with the good search function etc. You can also open the man page in a browser by adding -a <application\ name> after the open command. E.g. for Google Chrome:

mano() { MANWIDTH=100 MANPAGER='col -bx' man "$@" | open -f -a Google\ Chrome; }

tip source: scripting osx

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .