March 18, 2009

Open Files in Photoshop from Terminal

As I progress towards a pragmatic (and programmer’s) approach towards managing design files with version control, I needed a way to open files in Photoshop and other applications from the Terminal command line.

Since I am not a programmer, I decided to write a simple shell script to run my command. To do this (on a Mac), I created the file ‘psd’ in /usr/local/bin/ with the following code:

open -a “Adobe Photoshop CS3” “$@”

Next, I updated my bash profile to allow me to execute this from anywhere within my file system. To do this, I opened up my ‘.profile’ (located in ~/ or /Users/-username-), and added the following to the end of the first line:

:/usr/local/bin/psd

Now, from anywhere within the file system I can type the following to open the file in Photoshop:

sh psd filename.psd

This is much nicer than writing out the long “open -a …” command. This, of course, can be done for other applications, such as indd for InDesign, ai for Illustrator, etc.