Created
July 7, 2015 18:42
-
-
Save badsyntax/1f4a58715194d780b2f6 to your computer and use it in GitHub Desktop.
Open or reload a URL in Google Chrome with AppleScript
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
#!/usr/bin/env bash | |
osascript -e " | |
tell application \"Google Chrome\" | |
activate | |
set theUrl to \"$1\" | |
set found to false | |
set windowList to every window | |
repeat with aWindow in windowList | |
set tabList to every tab of aWindow | |
set tabIndex to 0 | |
repeat with atab in tabList | |
set tabIndex to tabIndex + 1 | |
if (URL of atab contains theUrl) then | |
set found to true | |
tell atab to reload | |
set aWindow's active tab index to tabIndex | |
end if | |
end repeat | |
end repeat | |
if not found then | |
open location theUrl | |
end if | |
end tell" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do we have an equivalent for MS Windows?