Viewing images from the Terminal in Mac OS X

Viewing images from the Terminal in Mac OS X
You can pass multiple images to the Preview app, very nice!

The more I learn and love FreeBSD the more I've been using the Terminal application on my Macs, to the point now where I'm using it more than any other application except perhaps a web browser: for file file compression and management the command line is so much quicker and simpler. As a result I've been trying to modify my workflow to allow me to work inside the Terminal even more, and I thought I'd share some tips I've picked up here.

One such example is viewing images and other media from the Terminal. Just as you probably use the bundled to do this when you're in the Finder or from the OPENSTEP days, you can also call it from the Terminal to do the same thing. For example, to load a picture called Geass.jpg:


And voila, Preview opens showing you the image you told it to load… from the Terminal! You can pass multiple images seperated with spaces, you can even mix in a few PDFs into your list. The scripting potential is just making me quiver with excitement!

A Mac OS X package

Why didn't I just call the application itself? Apps in Mac OS X are actually neatly contained in bundles (a special kind of folder) alongside other resources such as help files. The executable you want to call from the Terminal therefore is the program itself contained in the bundle, not the bundle itself.

Unfortunately there's bad news. As a guy learning UNIX I thought I'd be able to just generate a symbolic link to the executable so I could use a much shorter command in a manner line this:

% sudo ln -s \
/Applications/ \

Alas when I attempted to use the new command, I was given a plist error.

% preview_geass.jpg


This is one of about 5000 posts on Rubénerd. View the home page for the latest, or related posts also tagged with:

If you liked this post, feel free to buy me a coffee, leave me a comment on Twitter, or email me at Thanks :).