Skip to content

Instantly share code, notes, and snippets.

@rwest
Forked from risingspiral/rsync+watcher.rb
Created February 10, 2011 16:03
Show Gist options
  • Save rwest/820772 to your computer and use it in GitHub Desktop.
Save rwest/820772 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'osx/foundation'
OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
include OSX
$d=File.basename Dir.pwd
Dir.chdir '..'
fsevents_cb = proc do |stream, ctx, numEvents, paths, marks, eventIDs|
# system "rsync -L -C --delete -rt --rsh='ssh -p 2222' --exclude 'public/bundles' '#{$d}' 'eanderson@localhost:/home/eanderson/sandbox/'"
files = `rsync -raz --rsh=ssh --include='*.py' --exclude='*.*' --prune-empty-dirs --out-format='%n%L' '#{$d}/' 'rainier:eni/'`
system "growlnotify -m 'Synced #{files}'"
end
stream = FSEventStreamCreate(
KCFAllocatorDefault,
fsevents_cb,
nil,
[$d],
KFSEventStreamEventIdSinceNow,
1.0,
0)
die "Failed to create the FSEventStream" unless stream
FSEventStreamScheduleWithRunLoop(
stream,
CFRunLoopGetCurrent(),
KCFRunLoopDefaultMode)
die "Failed to start the FSEventStream" unless FSEventStreamStart(stream)
system "rsync -raz --rsh=ssh --include='*.py' --exclude='*.*' --prune-empty-dirs '#{$d}/' 'rainier:eni/'"
CFRunLoopRun()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment