Tell HN: On macOS, `man-preview` opens man pages in Preview

32 points by behnamoh ↗ HN
Basically the title. I'm ok with man pages; can navigate using typical Vim keybindings. But sometimes it's nice to see them as a PDF where you can quickly find the information you're looking for.

I thought maybe others will find it useful too.

20 comments

[ 4.3 ms ] story [ 46.4 ms ] thread
It tries to do something for me but fails, on Ventura.

Seems to just be a short script:

which man-preview man-preview () { man -w "$@" &> /dev/null && man -t "$@" | open -f -a Preview || man "$@" }

It looks like it's trying to pipe PostScript to Preview, which as of Ventura, no longer supports PostScript.
I've just now fixed it by passing the PostScript through ghostscript's ps2pdf:

man-preview () { man -w "$@" &> /dev/null && man -t "$@" | ps2pdf - - | open -f -a Preview || man "$@" }

I wonder where it was coming from - zsh on Mac OS? Homebrew?
(comment deleted)
Since the topic of readable man pages has come up: I would love it if there was a utility to rearrange man pages in roughly back-to-front order.

For example, this heading order is generally my preferred one:

Author, See Also, Example / Uses, Description, (and I typically find that I already know the Name but it's OK to add that at the end :-))

This comes from some personal preference, but is also informed by my professional work in coaching tech professionals.

In studying personality differences in tech, and listening to others' experiences in learning about tech, I developed a theory that a huge number of us get stuck attempting to read tech materials which were written by/from a completely opposite perspective (compared to our personal style) on why one reads, and what makes things readable.

This is like being nearsighted and borrowing a farsighted person's glasses, expecting them to work because glasses are what you wear to fix your eyesight.

In documentation, these two styles tend to draw battle lines around what you could call the man-forward or man-backward learning styles, IMO ;-)

`tldr` is one example of a countering man-backward app-psychology that is available and a fix for some of us, in some ways. But until the day of reconciliation arrives, I will continue to periodically leap forward and scroll backward...

Perhaps you are referring to the function provided by the ohmyzsh macos plugin?
Which MacOS version? Monterey 12.6.1 doesn't want to play ...
It was noted in another comment, but this is actually a function of the "macos" plugin for Oh My Zsh, and not a built-in thing.
I have a function in my .zshrc, copied from the internets

``` manps () { if [ -z "$1" ] then echo usage: $FUNCNAME topic echo This will open a PostScript formatted version of the man page for \'topic\'. else man -t $1 | open -f -a /System/Applications/Preview.app fi }

```

Poor forgotten xman.
I have the following in my .bash_profile for this purpose.

  pman() { man -t $@ | open -fa Preview.app; }
Thank you! That's awesome, so much nicer to read than in the terminal.

'man-preview' seems zsh only.

~ % which man-preview

man-preview not found

If you select a command and press 'Control+Command+?' it will open the man page in a new window. You can also customize the theme by editing the 'Man Page' profile in the settings.