4

If the MANPATH environment variable is set, man very "helpfully" ignores the default search path, as defined in /etc/manpath.config. Is there any way add a path or paths to that searched by man?

6

It depends on the man implementation, but since you have /etc/manpath.config I'm guessing that you're using a Debian-derived system with man-db.

In that case, manpath(1) describes what you can do here (and the same approach will work for man(1)):

If $MANPATH is prefixed by a colon, then the value of the variable is appended to the list determined from the content of the configuration files. If the colon comes at the end of the value in the variable, then the determined list is appended to the content of the variable. If the value of the variable contains a double colon (::), then the determined list is inserted in the middle of the value, between the two colons.

  • That explains why I have been able to get away with prefixing /path: to $MANPATH even when it starts out empty. – muru Nov 22 '17 at 1:41
3

Depending on the particular implementation of man, you may augment the value of MANPATH in different ways.

On Linux systems, set MANPATH to the value of manpath -g:

export MANPATH="$(manpath -g):/new/path/man"

or create an alias like

alias man='man -M "$(manpath -g):/new/path/man"'

On FreeBSD, do as above, but drop the -g.

On OpenBSD and NetBSD, use

alias man='man -m /new/path/man'

Consult the manual for the man utility on your Unix.

2

You can use manpath to build the current MANPATH and append the new path. To build the most inclusive path for your system, use the -g option:

export MANPATH=$(MANPATH= manpath -g):/new/man/path

Running manpath with an empty MANPATH ensures it ignores any current value of MANPATH.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.