If you’re like me, you love Coda. Well, you may find the need to open a file, or set of files, from Terminal in Coda. Gregory Tomlinson has created a bash script to let you do just that.
Update May 20, 2011: It turns out that Tomlinson’s website is down. So, here is a brief synopsis of what you can do to add this functionality to your Mac.
- Open Terminal
- In terminal, enter: open .profile
- Add the following lines of code
# TextMate
# set path and simple shell function
export TEXTMATE_PATH=/Applications/TextMate.app/Contents/Resources/mate
mate () {
$TEXTMATE_PATH $1 $2 $3 $4 $5 $6
}
# svn for TextMate (default editor, end-of-line types)
export EDITOR="$TEXTMATE_PATH -w"
export LC_CTYPE=en_US.UTF-8# Coda
# set path
export CODA_PATH=/Applications/Coda.app
# function roughly like 'mate .' by expanding '.' to '*.htm*'
coda () {
if [[ "." == $1 ]]
then
open -a $CODA_PATH *.htm*
else
open -a $CODA_PATH $1 $2 $3
fi
} - Save .profile
- Quit Terminal
- Restart Terminal
There is also a slightly more robust script written for Coda by Aditya Bhargava that handles a few more tidbits and it is available on GitHub.
HI Colin
I am actually able to open directories with that script into Coda. If you are getting a specific error, please let me know.
thanks
-gregory
No error. How do you do it?
coda .
I use textmate myself, but have a buddy who is a Coda die hard… was looking for a bash script that allowed the “coda .” command and found your site. Trouble is, that link is broken…
Anyway you could post the bash script up yourself?
Emerson: I don’t have it any longer. However, I am going to email Gregory this comment and ask that he paste it below.
#! /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
## usage
$: coda myFileToOpenOrCreate
$: coda *.txt
Thanks Gregory. (There you go Emerson)