8

Apple has some custom URLs defined and one of them is x-man-page. If you open a particular man page with it, it displays it in a nice yellow window (a provided profile for Terminal) with black text.

open x-man-page://man

enter image description here

Side note: You can even put this on a web-page and it will automatically open the man page in the URL. It was "categorized" as a security issue (Stack Exchange prohibits the URL), but at most it's a nuisance. Same goes for the dictionary app: open x-dictionary:apple, but I digress...

What's nice about it is that it's a separate window and it has it's own predefined profile that can be customized (but I like the default)*. This is the same functionality if you select a command in Terminal with your mouse, right click and select "Open man page".

I would like to this to work in iTerm2

Using RCDefault App I set the application for x-man-page and when I issue the command, it does open a new iTerm tab, but it displays nothing.

Does anyone know how to get iTerm2 to respond to this?


*I liked it so much, I wrote this function in my .bash_profile so that if I type man <command> it shows up as if I typed open x-man-page://<command>

function man {
if [ $# -eq 1 ] ; then
  open x-man-page://$1 ;
elif [ $# -eq 2 ] ; then
  open x-man-page://$1/$2 ;
fi
}
1
  • 1
    An alternative is to use the app ManOpen that shows a man page in a separate nicely formatted window. In macports port install ManOpen does this - But seemingly not on Monterey - I have used it for 15+ years. The original site appears to be missing as well but there are forks on GitHub
    – mmmmmm
    Commented Dec 17, 2021 at 23:42

2 Answers 2

1

It doesn't seem like iTerm actually supports a graphical manpage viewer like Terminal does.

That said, you can force iTerm to open that URL scheme by doing this:

open -a iTerm x-man-page://ls

But when I do that all iTerm does is open a new terminal. It seems like it should at least open up a new terminal with the manpage shown, but it doesn't work for me. This feature doesn't seem to be mentioned in iTerm's documentation either. It's a mystery why it registers that URL scheme. My guess is that this was an older feature that's no longer supported and it's a bug that it still registers for the x-man-page scheme.

1
1

What the "manpage viewer" does is basically just running the command man -P ul SECTION NAME in the “man page profile” and just terminate. The x-man-page url scheme is bound to Terminal.app in LaunchServices, with a corresponding AppleEvent handler in the app. I don't think changing it, or adding it to iTerm without developer’s support would be easy. If you can program the iTerm to open a similarly formatted link in the aforementioned way, and make it a "service" that appears in the context menu, you would mostly achieve what you wanted.

You must log in to answer this question.

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