6

How to set $MANPATH or manpath for the macOS Terminal Help menu command: Open man Page for Selection?

Having recently done a clean install of macOS Mojave (10.14.6), I am trying to get my macOS Terminal.app configured. The trouble is with the Terminal menu command Open man Page or Open man Page for Selection and its associated service available system wide in the Services menu. I would like to configure the manpath that the menu command is using to be the same as my bash shell.

The standard /usr/bin/man command works great from my shell. But I like to be able to select a word or topic or command in the Terminal and right click. The context menu has Open man Page and Services ► Open man Page in Terminal. I use the last one a lot becase it works anywhere. The menu command opens a new window in Terminal containing the complete formatted man page text, with a special window profile / color scheme, without disturbing my current shell session.

My specific problem is illustrated as follows. If I select "bash", right click, and Open man Page, then the man page I get is for bash 3.2. It is almost certainly the from /usr/share/man/man1/bash.1.
If I type man bash in the Terminal shell, I get the man page for bash 5.0: /usr/local/share/man/man1/bash.1. Typing man -aw bash, I get

$ man -aw bash
/usr/local/share/man/man1/bash.1
/usr/share/man/man1/bash.1
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/share/man/man1/bash.1

If I type manpath, replacing colons with newlines, I get

$ manpath | perl -nE 's/:/\n/g; print'
/opt/local/share/man
/usr/local/share/man
/usr/share/man
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/share/man
/Applications/Xcode.app/Contents/Developer/usr/share/man
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man
/usr/local/opt/ack/share/man

I don’t know how to query the Terminal for manpath it is using, or configure it. Please help with any advice on how to configure the Terminal menu command Open man Page for Selection.


More information:

cbedgar@CBmac: ~  | 14:22:38 | -bash5.0.11
293$ man -d
Reading config file /private/etc/man.conf
Looked whether there exists a message catalog man, but there is none
(and for English messages none is needed)

found man directory /usr/local/share/man
found man directory /opt/local/share/man
found man directory /usr/share/man
found man directory /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/share/man
found man directory /Applications/Xcode.app/Contents/Developer/usr/share/man
found man directory /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man
found man directory /usr/local/opt/ack/share/man
found man directory /usr/local/opt/bash/share/man
found man directory /usr/local/opt/gdbm/share/man
found man directory /usr/local/opt/gettext/share/man
found man directory /usr/local/opt/gnupg/share/man
found man directory /usr/local/opt/gnupg2/share/man
found man directory /usr/local/opt/[email protected]/share/man
found man directory /usr/local/opt/gnutls/share/man
found man directory /usr/local/opt/gpg/share/man
found man directory /usr/local/opt/gpg2/share/man
found man directory /usr/local/opt/grep/share/man
found man directory /usr/local/opt/jq/share/man
found man directory /usr/local/opt/libevent/share/man
found man directory /usr/local/opt/libffi/share/man
found man directory /usr/local/opt/libgcrypt/share/man
found man directory /usr/local/opt/libgpg-error/share/man
found man directory /usr/local/opt/libidn2/share/man
found man directory /usr/local/opt/libtasn/share/man
found man directory /usr/local/opt/libtasn1/share/man
found man directory /usr/local/opt/libxml2/share/man
found man directory /usr/local/opt/openssl/share/man
found man directory /usr/local/opt/[email protected]/share/man
found man directory /usr/local/opt/pandoc/share/man
found man directory /usr/local/opt/pcre/share/man
found man directory /usr/local/opt/pcre1/share/man
found man directory /usr/local/opt/perl/share/man
found man directory /usr/local/opt/[email protected]/share/man
found man directory /usr/local/opt/pure-ftpd/share/man
found man directory /usr/local/opt/python/share/man
found man directory /usr/local/opt/python2/share/man
found man directory /usr/local/opt/python3/share/man
found man directory /usr/local/opt/python@2/share/man
found man directory /usr/local/opt/python@3/share/man
found man directory /usr/local/opt/readline/share/man
found man directory /usr/local/opt/sqlite/share/man
found man directory /usr/local/opt/sqlite3/share/man
found man directory /usr/local/opt/unbound/share/man
found man directory /usr/local/opt/xz/share/man
found manpath map /bin --> /usr/share/man
found manpath map /sbin --> /usr/share/man
found manpath map /usr/bin --> /usr/share/man
found manpath map /usr/sbin --> /usr/share/man
found manpath map /usr/local/bin --> /usr/local/share/man
found manpath map /usr/local/sbin --> /usr/local/share/man
found manpath map /usr/X11/bin --> /usr/X11/man
found manpath map /usr/bin/X11 --> /usr/X11/man
found manpath map /usr/bin/mh --> /usr/share/man

using /usr/bin/less -is as pager

using /usr/bin/less -is as browser

using /bin/cat to dump HTML pages as textWhat manual page do you want?
5
  • run man manpath or man man to see details. /private/etc/man.conf is where the configuration file sits. I just saw this thing for the first time, so cannot add more.
    – anki
    Commented Dec 6, 2019 at 17:49
  • 1
    Can your post the command and results of man -d ?
    – fd0
    Commented Dec 6, 2019 at 18:58
  • 1
    The man pages for manpath and man have been open all morning, but good suggestion anyway. The user guide for Terminal wasn't much help either. I had tried editing /etc/manpaths or adding a file to /etc/manpaths.d/ and rebooting to no avail. Editing /etc/man.conf was a great thought, so I just tried adding my changes and rebooting. No difference. I still get the wrong bash manual. THANK YOU for the suggestions however. Commented Dec 6, 2019 at 19:33
  • I suspect this is the uual issue of running from Finder as Terminal does - then your ~/.bash_profile etc are not loaded.
    – mmmmmm
    Commented Jan 16, 2023 at 0:02
  • For bash, I would put the MANPATH definition into your .bashrc ; but test it first inside your bash shell, whether it works, before editing your startup file. Commented Nov 20, 2023 at 13:34

1 Answer 1

1

In my use case, Terminal Open man Page was not working for 3rd-party software on Apple ARM-based macOS Ventura. e.g., Homebrew, MacTeX.

Also, the x-man-page:// URI Scheme for Terminal.app was not working in the same scenario. Example use of x-man-page in markdown:

FFmpegQuickReference.md

# [FFmpeg][t] Quick Reference
[t]:x-man-page://1/ffmpeg

man pages: [ffmpeg](x-man-page://1/ffmpeg), [ffprobe](x-man-page://1/ffprobe)

… snip …

The Ventura man page shows /usr/local/etc/man.d in the FILES section:

FILES
     /etc/man.conf
             System configuration file.
     /usr/local/etc/man.d/*.conf
             Local configuration files.

Here's a solution for macOS Ventura (Apple ARM) which worked for both Open man Page menu item and x-man-page URI:

### check for presence of man.d directory
ls -l /usr/local/etc
### add these directories if not already present
sudo mkdir /usr/local/etc
sudo mkdir /usr/local/etc/man.d

cd /usr/local/etc/man.d
sudo touch man.conf
sudo nano man.conf

### View in Finder:
open /usr/local/etc

Contents of /usr/local/etc/man.d/man.conf:

### :EDIT:2023.10.01: Created /usr/local/etc/man.d/man.conf

### Homebrew
MANPATH /opt/homebrew/share/man
MANPATH /opt/homebrew/Cellar/*/*/share/man

### MacTeX 2023
MANPATH /usr/local/texlive/2023/texmf-dist/doc/man

### XQuartz X11
MANPATH /opt/X11/share/man

Alternately, a *.man.conf file can be created for each 3rd-party distribution.

usr
└── local
    └── etc
        └── man.d
            ├── homebrew.man.conf
            ├── mactex.man.conf
            └── xquartz.man.conf

Addendum

See Homebrew issue "Terminal.app 'Open man Page' context menu and 'x-man-page' URI scheme not working in Apple Silicon for brew formulae" for additional discussion on this topic.

1
  • One caveat is that /etc/man.conf has precedence over /usr/local/etc/man.d/*.conf . If you install a newer version of a system package via Homebrew (e.g. rsync), the Terminal.app will continue using the old man.
    – Kentzo
    Commented Jan 25 at 23:33

You must log in to answer this question.

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