Generate a PDF Copy of the Man Page for a Shell Command

(I had to correct this a couple of times, kindly look at the final version, please.)


Enscript (installed using HomeBrew) is a possibility, if "enscript.cfg" is modified so that the line

DefaultOutputMethod: printer

is changed to

DefaultOutputMethod: stdout

In that case, a pipe such as

enscript --filter="transcode-video --help" | pstopdf -l -o ~/desktop/onefile.pdf

is successful.

However, substituting

enscript --filter=$CMD | pstopdf -l -o $MANPDF


man -t $CMD | pstopdf -l -o $MANPDF

in the macro didn't work, apparently because "transcode-video --help" when entered into the dialog, is interpreted as two separate commands.

So that's one issue to be solved (my proficiency is mainly limited to AppleScript), and the second is to fork between the two command versions based on a conditional (should be easy to trap an error when either executable doesn't receive correct input).

I still used to get better results with "open -f -a /Applications/" (before prepending the app path with "/System" was required).

"| open -f -a /Applications/" is still beneficial to some extent, however.

Skip the path – use:

open -f -b

I don't know anything about enscript, so you're on your own with that.


Thanks. I just need for "transcode-video --help" to be interpreted as a single command (step 6: "Enter the names of one or more shell commands:"). I need the possibility of more than one shell command not to be considered.

It would help to post the origin of this. I'm guessing it's this:

If you want the result of:

transcode-video --help

One way to do it is to place it in a subshell:

$(transcode-video --help)