Skip to content

Instantly share code, notes, and snippets.

@jaredhabeck
Created April 17, 2012 16:26
Show Gist options
  • Save jaredhabeck/2407307 to your computer and use it in GitHub Desktop.
Save jaredhabeck/2407307 to your computer and use it in GitHub Desktop.
osascript to reload chrome or firefox, make reloadbrowser.sh available to watchr via PATH or otherwise...
#!/usr/bin/osascript
-- setting to return focus to the initial calling app (in my case it's Textmate)
set callingApp to (path to frontmost application as Unicode text)
-- tell application "Google Chrome"
-- activate
-- end tell
--
-- tell application "System Events"
-- tell process "Google Chrome"
-- keystroke "r" using {command down}
-- end tell
-- end tell
tell application "Firefox"
activate
end tell
tell application "System Events"
tell process "Firefox"
keystroke "r" using {command down}
delay 0.1
end tell
end tell
-- return focus to calling app
tell application callingApp
activate
end tell
# to be placed in a rails project at the top level, then run:
# watchr script.file
# regex is a bit too greedy I think...
# this also assumes the reloadbrowser script is in your PATH (mine is in /usr/local/bin)
watch( 'app/(.*/.*)(\.js|\.scss|\.haml)' ) {|md| system("reloadbrowser") }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment