Skip to content

Open PostScript files in Preview in macOS Ventura

One major change in macOS Ventura is that Preview can no longer display PostScript files. Apple hasn't explained why they've made this change, but many think it's due to possible security issues with PostScript files.

Whatever the reason, this change broke one of my most-used Terminal functions:

pman name-of-command

This function opens the specified command's man page in Preview, nicely formatted using PostScript. Or at least, it did. The function itself, as defined in my .profile file, was very simple:

# Open man pages in Preview
function pman()
{
    man -t "${1}" | open -f -a Preview.app
}

But this now fails because Preview won't parse the PostScript file. There are two solutions for this, one that relies on an external package (which is the solution I found), and another using only macOS' built-in tools (which I found just after finishing this writeup).

Built-in solution

The replacement function for my old pman command looks like this:

function pman()
{
    mandoc -T pdf "$(/usr/bin/man -w $@)" | open -fa Preview
}

Armin Briegel posted the above solution on his blog, Scripting OS X. I've tested it, and it works well—it's the solution I'm using, in fact, because it's much faster than my solution.

External tools solution

Before I found the above-linked page, I found a solution that relies on Ghostscript, which I installed it via Homebrew (brew install ghostscript).

The package contains a number of tools for working with PostScript; the one of interest to me is ps2pdf, which does what you might guess: Converts PostScript files to PDF files. With Ghostscript installed, my slightly more complicated (though still one line) function now looks like this:

# Open man pages in Preview
function pman()
{
    man -t "${1}" 2>/dev/null | /usr/local/bin/ps2pdf - - | open -f -a Preview.app
}

The man command generates the PostScript output (and suppresses any errors), which is then piped to the ps2pdf converter1If you didn't install ps2pdf with homebrew, replace the path above with the proper path on your system., whose command line options indicate that it should accept standard input (the output from the man command) and send its results to standard output, which is then piped to the Preview app.

Either of these will work, but the first method, using only built-in tools, is notably faster. From Armin's blog, I also discovered that you can open any man page in a separate "man page" Terminal window by using the x-man-page URL scheme:

open x-man-page://zsh, open x-man-page://ln, etc.

Neat!

3 thoughts on “Open PostScript files in Preview in macOS Ventura”

  1. I am pretty sure I learned about opening Mac pages in Terminal on macosxhints.com initially. It is a tool I have found to useful to have and share for a long time now, so I love that I could "give it back" this way.

  2. Thank you so much for putting this tutorial together.

    I've recently installed a PiStorm expansion card in my Amiga 1200 tower, giving the machine far more power than it's ever had, and making it useable for many tasks including DTP and word processing. The issue I had is that few Amiga applications export to PDF, and my wireless HP printer isn't compatible with the Amiga.

    Following your instructions I can now save my output as postscript on the Amiga, FTP the file over to my Mac and convert to PDF with ps2PDF. From the Mac I can then print the file out.

    I'm sure it would be easier to do all this just on the Mac, but where's the fun in that?

    Thanks again,

    Rob

Leave a Reply to Armin Briegel Cancel reply

Your email address will not be published. Required fields are marked *