Sublime Forum

Send to Transmit on Save for ST2

#1

I use the DockSend feature of Transmit (a Mac FTP client) to mirror local files to the server, so I whipped up a little script to automatically send the current file to Transmit after a save.

Sometimes I work without a connection and don’t want Transmit to start throwing errors, so the script first checks to see if I have Transmit running.

I keep all my mirrored projects in a specific folder, so it also checks if the file is inside that folder. You’d have to change this value to suit your needs, and you could also remove the checks if you wanted. You could also, of course, change Transmit to Interarchy or any other client with similar functionality.

It uses AppleScript so it’s Mac-only.

This is my first time using Python, so forgive any sloppy coding.

Just past the code into a file called send_to_transmit.py and save it to Packages/User/

[code]import sublime, sublime_plugin
import os

class SendToTransmit(sublime_plugin.EventListener):
def on_post_save(self, view):
cmd = “ps ax | grep -v grep | grep Transmit”
if os.system(cmd) == 0:
if view.file_name().count(’/Users/dmatarazzo/Mirrors/’) > 0:
cmd = “”“osascript -e 'tell app “Transmit” to open POSIX file “”” + ‘"’ + view.file_name() + ‘"’ + “’”
os.system(cmd)
print “Sent file to Transmit”[/code]

0 Likes

#2

Awesome!

I need something like this for Windows, using Filezilla.

Omnomnom.

0 Likes

#3

@n00ge and I worked on this a bit and have come up with one that runs on a key command and is directory independent

check it out here

github.com/brickattack/st2-send_to_transmit

0 Likes

#4

Sweet! I’ve been looking for that. Thanks!

0 Likes

#5

It doesnt work for me on the version 2, I just clone the git to ~/Library/Application Support/Sublime Text 2/Packages/ i see all the files on the folder st2-send_to_transmit but when I press ctrl+super+f it doesnt upload (but with textmate it works).

0 Likes

#6

Take a look at the Keep Remote Directory up to Date feature of WinSCP (which, despite the name, also does FTP).

0 Likes