Skip to content

Instantly share code, notes, and snippets.

@chemzqm
Last active January 29, 2016 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chemzqm/3fdafa6df233d11e1442 to your computer and use it in GitHub Desktop.
Save chemzqm/3fdafa6df233d11e1442 to your computer and use it in GitHub Desktop.
Fixed open url for Chrome
#!/usr/bin/env bash
if [[ $1 =~ ^http.* ]]; then
file=$1
else
file=file://`realpath $1`
fi
cat << EOF | sed "s+full_path+$file+" | osascript -
if application "Google Chrome" is not running then
tell application "Google Chrome"
activate
delay 0.2
end tell
end if
set findtab to false
tell application "Google Chrome"
set window_list to every window
repeat with the_window in window_list
set tab_list to every tab in the_window
set num to 0
repeat with the_tab in tab_list
set num to num + 1
set the_url to the URL of the_tab
if the_url starts with "full_path" then
set active tab index of the_window to num
set findtab to true
tell the_tab
reload
end tell
end if
end repeat
end repeat
if not findtab then
open location "full_path"
end if
end tell
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment