Open or Create a file in Terminal to Coda

I have recently started using Coda by Panic (the people who make Transmit). I have to say I really like it. I have been a die hard BBEdit fan for years and was hesitant to make the switch. However, a co-worker was talking up Coda and mentioned that it had auto-complete – a feature that has been sorely lacking from BBEdit.

The switch turned out to be fairly painless. One feature that I really missed from BBEdit was the ability to create or open files from the command line simply by invoking the following

$: bbedit -c myFileToOpen

Sadly, Coda didn’t appear to have the same functionality. I contacted the Coda team, they liked the idea and planned to look into it, but I am way too impatient to wait. In the meantime, I decided to write my own little bash script that I named ‘coda’

#! /bin/bash 
if [ "$1" = "" ]; then
	echo "Please specify a file to open or create"
	exit 0
else
	for ARG in $*
		do
    	            touch -a $ARG && open -a Coda $ARG 
		done
	exit 0
fi

By using touch, I am able to create a file if it doesn’t exist. I pass the ‘a’ argument, but not the ‘m’ argument so the timestamp doesn’t change for already existing files. After touch works its magic, the open command opens the file in Coda. I am running a for loop over the list of arguments in order to allow a list of files or a wildcard as well as a single file to be passed into the script. Sweetness! I threw this little script in my bin folder and set it to executable using chmod +x. Using the script looks like this

$: coda myFileToOpenOrCreate
$: coda *.txt
  • Margo Esquandolas
    BBEdit has automatic text completion.
  • @Margo

    I'm not sure what you consider automatic text complete, but BBedit doesn't have auto complete text while you type for HTML / CSS / JavaScript. It definitely has the HTML tool panel which allows you to click buttons and have tags inserted, but that is not nearly as useful as what Coda provides.

    If you know of some key commands that insert HTML tags please share.
  • Bomba
    I get this error:

    2008-10-21 13:05:53.386 coda[15623:10b] No Info.plist file in application bundle or no NSPrincipalClass in the Info.plist file, exiting
  • @bomba

    interesting, not sure why it would do that, wonder if some special characters made it into the code.

    I also have the developer tools installed, but other than that it is a regular old bash shell
  • Johnny
    works like a charm for me! thanks, buddy!!! :)
  • joe
    genius! thanks.
blog comments powered by Disqus