Created
June 7, 2010 03:00
-
-
Save mustardamus/428174 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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