Skip to content

Instantly share code, notes, and snippets.

@mustardamus
Created June 7, 2010 03:00
Show Gist options
  • Select an option

  • Save mustardamus/428174 to your computer and use it in GitHub Desktop.

Select an option

Save mustardamus/428174 to your computer and use it in GitHub Desktop.
require "rubygems"
require "directory_watcher"
unless ARGV[0]
puts "Usage: brundle.rb [path to watch]"
exit
end
commands = [
{ :tell => "Firefox", :to => "activate" },
{ :tell => "System Events", :to => "keystroke \"1\" using command down" },
{ :tell => "System Events", :to => "keystroke \"r\" using command down" },
{ :tell => "TextMate", :to => "activate" }
]
dw = DirectoryWatcher.new ARGV[0]
dw.interval = 1.0
dw.glob = "**/*.*" #or just specific files: "**/*.{erb,less,css}"
dw.add_observer {|*args| args.each {|event|
unless event.type == :added
commands.each do |command|
%x[osascript -e 'tell application "#{command[:tell]}" to #{command[:to]}']
end
end
puts event
}}
trap("SIGINT") do
dw.stop
exit
end
dw.start
while(true) do
sleep 60
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment