Created
March 11, 2010 00:15
-
-
Save andrewle/328631 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/sh | |
# Textmate command that uses AppleScript to switch to Firefox, reload | |
# the browser, and then switch back to Textmate | |
# I have this bound to Ctl-Opt-Command R | |
# | |
# Save: Nothing (or Current File is useful too) | |
# Input: None | |
# Output: Discard | |
# | |
{ | |
osascript -e " | |
tell application \"Firefox\" | |
activate | |
end tell | |
tell application \"System Events\" | |
tell process \"Firefox\" | |
keystroke \"r\" using {command down} | |
end tell | |
end tell | |
delay 1 | |
tell application \"Textmate\" | |
activate | |
end tell" | |
} |
Save yourself some escaped quoting and leverage osascript
's ability to read from stdin. (HEREDOC if you want to mix interpreters with bash
/sh
.
#!/usr/bin/osascript
-- reload firefox using cmd + R
tell application "Firefox"
activate
end tell
tell application "System Events"
tell process "Firefox"
keystroke "r" using {command down}
end tell
end tell
-- no need to wait.
tell application "Textmate"
activate
end tell
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome, thanks!