Skip to content

Instantly share code, notes, and snippets.

@risingspiral
Forked from mxcl/rsync+watcher.rb
Created December 6, 2010 19:18
Show Gist options
  • Save risingspiral/730770 to your computer and use it in GitHub Desktop.
Save risingspiral/730770 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/'"
system "growlnotify -m 'Synced #{numEvents} 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 -L -C --delete -rt --rsh='ssh -p 2222' --exclude 'public/bundles' '#{$d}' 'eanderson@localhost:/home/eanderson/sandbox/'"
CFRunLoopRun()
@risingspiral
Copy link
Author

Added a growlnotify call and personalized rsync call

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