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:
- The Sublime Text editor itself (where all the coding action happened)
- Terminal (where I would interface with the server)
- Panic’s Transmit (if needed when uploading images, etc.)
- 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
- Save your
.bash_profile
- 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!