Open a man
page as PDF on macOS
In the afternoon I found a nice Bash function in the comments section of Hacker News by user danielecook, reformatted to fit the width of this page:
function pman() {
man -t ${1} |
open -f -a \
/Applications/Preview.app
}
It calls man
with the given argument and the -t
option, which
outputs the man page as PostScript. This output is piped to the open
command with the -f
option to read from standard in, the pipe in
this case, and opens the application specified with -a
with this
output.
Very neat.