Skip to content

Instantly share code, notes, and snippets.

@kimchaily
Created April 16, 2015 15:46
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimchaily/5e39f9ef2d5040a60c43 to your computer and use it in GitHub Desktop.
Save kimchaily/5e39f9ef2d5040a60c43 to your computer and use it in GitHub Desktop.
Alfred workflow. Open a new window in Chrome and if URL given, then go to that URL
on alfred_script(q)
if not (q starts with "http://")
set q to "http://" & q
end if
tell application "/Applications/Google Chrome.app"
make new window
set URL of active tab of window 1 to q
end tell
end alfred_script
@b-d-m-p
Copy link

b-d-m-p commented Jun 7, 2016

This is great! How can I implement it? I tried setting up a workflow but couldn't get it working. Any suggestions would be appreciated.

Copy link

ghost commented Aug 24, 2016

My workflow is to use a keyword then run the script above minus the if statement and then use the Open URL action. If you are wanting to do this for any domain just use {query} in the Open URL action. If you don't need a new window skip the script entirely.

Keyword > NSAppleScript > Open URL. You can chain URL's as well.

Keyword > NSAppleScript > Open URL > Open URL > Open URL

screen shot 2016-08-24 at 9 47 50 am

@SRL20
Copy link

SRL20 commented Jun 20, 2018

I've been using this for a long time, it's super helpful!

I'm trying to adjust it for use with Safari 11.1, but having trouble. All URLs keep opening in the same window. Aiming to have different windows for specific sets of URLs. Any ideas on how to swap Chrome for Safari?

@jame-zhang
Copy link

jame-zhang commented Dec 6, 2018

thanks for sharing
modified: open url in new tab if chrome is running otherwise in new window, link

Copy link

ghost commented Feb 22, 2019

And it still works!

@Rogersjk
Copy link

Great, it's very useful! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment