Skip to content

Instantly share code, notes, and snippets.

@unixmonkey
Created December 20, 2012 14:28
Show Gist options
  • Select an option

  • Save unixmonkey/4345582 to your computer and use it in GitHub Desktop.

Select an option

Save unixmonkey/4345582 to your computer and use it in GitHub Desktop.
A SublimeText 2 Plugin to auto-scp files to an ssh server on save http://net.tutsplus.com/tutorials/python-tutorials/how-to-create-a-sublime-text-2-plugin/
import sublime_plugin, os
class RemoteEdit(sublime_plugin.EventListener):
def on_post_save(self, view):
remote = { "/local/path/to/project": "/usr/bin/scp '$1' username@remote_host:'/remote/path/to/project$2'" }
for dirname, target in remote.iteritems():
if view.file_name().startswith( dirname ):
target = target.replace( "$1", view.file_name() )
target = target.replace( "$2", view.file_name()[len(dirname):] )
fname = view.file_name().replace(dirname, '')
os.system( target + " &" )
os.system( "/usr/local/bin/growlnotify -m 'Copied %s'" % fname )
@User1005
Copy link

User1005 commented Nov 9, 2015

Hello! I tried to install this on my MacBook with Mavericks. I followed the tutorial on tutsplus (link in description) and changed the paths and login but after saving the plugin and restarting Sublime Text 2 nothing changed. Every time I hit cmd+s the sublime console does not do anything new. Is there a special trick to load the plugin? Where do I get asked for my ssh password? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment