How To Easily Open A File From Terminal In Coda 2

I’ve been playing a lot more with Coda 2 upon purchasing it since its initial release a couple of weeks ago. While I had been teetering on purchasing version 1 last year, I held off on anticipation of the version 2 release. In the meantime I played with Sublime Text 2.

While I’m certainly no coding ninja I did find Sublime Text 2 a little difficult to undertake all my grasshopper coding stuff. In most cases I found 4 pieces of software open for my workflow:

  1. The Sublime Text editor itself (where all the coding action happened)
  2. Terminal (where I would interface with the server)
  3. Panic’s Transmit (if needed when uploading images, etc.)
  4. The browser (to check everything was working)

During this time I wore out my ⌘-Tab keys a lot!

Thankfully, when Coda 2 was released I jumped at the opportunity and bought straight away. All the things I have open in my Sublime Text 2 workflow were now all rolled into one nice neat piece of software.

However, upon using it more I did begin to ask myself the question: How can I open files from the command-line in Terminal and have them opened in Coda 2’s text editor?

For example, if I run the command:

$ coda test.js

I want text.js now opened as a tab in the text editor, and if text.js hasn’t been created or doesn’t exist in the current working folder then create it.

After scouring the internet for a while I stumbled upon Noah Frederick’s shell script code and slightly modified it to allow what I wanted in my Terminal. Here’s what I did to get it to work:

Open up Terminal and navigate to your home directory (generally cd ~ or wherever your .bash_profile file is)

$ cd ~

Edit your .bash_profile file by copying and pasting the code found below – I usually do quick edits in Terminal by using:

$ nano .bash_profile
  1. Save your .bash_profile
  2. Restart your .bash_profile with the command:
$ source .bash_profile

Test your code by opening a file and then creating a file – hopefully it all works!


Author of, Ryan has been dabbling in code since the late '90s when he cut his teeth by exploring VBA in Excel when trying to do something more. Having his eyes opened with the potential of automating repetitive tasks, he expanded to Python and then moved over to scripting languages such as HTML, CSS, Javascript and PHP. When he is not behind a screen, Ryan enjoys a good bush walk with the family during the cooler months, and going with them to the beach during the warmer months.

Recent Posts