I have long been a big fan of Textmate, but about 6 months ago I decided to take Coda for a spin.
Coda is great, I just love the feel of Textmate more. It was tough though giving up the integrated publishing option that is included in Coda. I know you can send using Transmit and docklets but I wanted something that synched.
If anyone else has been looking for similar functionality here’s how I did it.
Firstly, you need to download and install lftp. This great utility can be found here. It comes as a source tarball and installing requires that you first have pkg-config installed which requires a bunch of other dependencies. I ended up just using macports to get all this stuff installed with:
sudo port install lftp
Once lftp is installed it’s time to write a script to use this in the bundle editor. I decided that I would create a project.xml in the root of the project directory that had all the relevant information.
Here was my first attempt:
<project>
<title>For Future Purposes</title>
<server>
<location>sftp://username:password@mydomain.com</location>
<path>/var/www/html/test_proj</path>
</server>
<exclude>
<file>project.xml</file>
<file>dont-synch</file>
<file>synchthisdir/dont synch this file</file>
</exclude>
</project>
From there I simply wrote a little python script that gets called from the bundle editor in textmate.
#!/usr/bin/python
import os
from xml.etree.ElementTree import ElementTree
os.system('cd %s' % os.environ['TM_PROJECT_DIRECTORY'])
tree = ElementTree()
tree.parse('project.xml')
host = tree.find('./server/location').text
path = tree.find('./server/path').text
excludes = tree.findall('./exclude/file')
exclude = ""
for item in excludes:
exclude = exclude + "--exclude-glob \'%s\' " % item.text
command = 'lftp -c "open %s;cd %s;mirror --reverse %s"' % (host,path,exclude)
#print command
os.system(command)