I want my Wikipedia search to open in Google Chrome…
A few users have posed the question “How can I open a particular custom search in a browser other than my default”… what a great question, perfect for a little tumble tutorial! :)

This behaviour isn’t built into Alfred by default as he is generally agnostic to the underlying OS so we must delve into [Powerpack] extensions and create a few very simple scripts.
My default browser is Safari, I am going to create a ‘wiki’ keyword which opens wikipedia for the given search term in Google Chrome. If you aren’t bothered about this tutorial, just download these extensions which give examples of opening a wikipedia custom search in Google Chrome, Safari and Firefox.
1. Create a Script Extension
In Alfred’s Extension preferences, create a new script extension and give it a name. I will call mine “Wiki in Chrome” and have filled in my name and web address so people can see that I created it. Adding a Google Chrome icon helps quickly identify it in the results.
2. Enter a Title, Description and keyword
I have used ‘Wiki {query}’ for the title as {query} is dynamically replaced out when shown in the results like the standard web searches. Adding a description helps the user see what this search is going to do. Naturally, setting the keyword to ‘wiki’ makes sense.
Make sure the ‘silent’ checkbox is ticked as this will make the browser launch from Alfred directly without opening Terminal.app
3. Entering the Shell command
We need to open Google Chrome and pass the URL, this is actually a really simple task in Shell:
open -a "/Applications/Google Chrome.app" "http://en.wikipedia.org/wiki/Special:Search/{query}"
Breaking this command down…
‘open’ tells shell that you want to open something.
‘-a’ tells the open command that we want an application
The browser is passed after the -a
The website URL is passed after the browser including {query}
4. Tweaking the advanced options
Without going into details, using shell scripts can have funny and incompatible side effects with arguments so in this extension’s advanced options we don’t want to escape spaces, brackets or semicolons. Leave everything else as default in the advanced prefs.
5. Save, Test and we are good to go!
Click the ‘Save’ button then open Alfred and type ‘wiki bananas’, selecting the result which relates to this extension (not the default Alfred wiki result).
Hope this helps you get started with creating your own extensions!
Cheers,Andrew@preppeller
Note: You could achieve the above extensions with better escaping of parameters by using an AppleScript extension - possibly something for a future tumble :)

I want my Wikipedia search to open in Google Chrome…

A few users have posed the question “How can I open a particular custom search in a browser other than my default”… what a great question, perfect for a little tumble tutorial! :)

Download Extension

This behaviour isn’t built into Alfred by default as he is generally agnostic to the underlying OS so we must delve into [Powerpack] extensions and create a few very simple scripts.

My default browser is Safari, I am going to create a ‘wiki’ keyword which opens wikipedia for the given search term in Google Chrome. If you aren’t bothered about this tutorial, just download these extensions which give examples of opening a wikipedia custom search in Google Chrome, Safari and Firefox.

1. Create a Script Extension

In Alfred’s Extension preferences, create a new script extension and give it a name. I will call mine “Wiki in Chrome” and have filled in my name and web address so people can see that I created it. Adding a Google Chrome icon helps quickly identify it in the results.

2. Enter a Title, Description and keyword

I have used ‘Wiki {query}’ for the title as {query} is dynamically replaced out when shown in the results like the standard web searches. Adding a description helps the user see what this search is going to do. Naturally, setting the keyword to ‘wiki’ makes sense.

Make sure the ‘silent’ checkbox is ticked as this will make the browser launch from Alfred directly without opening Terminal.app

3. Entering the Shell command

We need to open Google Chrome and pass the URL, this is actually a really simple task in Shell:

open -a "/Applications/Google Chrome.app" "http://en.wikipedia.org/wiki/Special:Search/{query}"

Breaking this command down…

  1. ‘open’ tells shell that you want to open something.
  2. ‘-a’ tells the open command that we want an application
  3. The browser is passed after the -a
  4. The website URL is passed after the browser including {query}

4. Tweaking the advanced options

Without going into details, using shell scripts can have funny and incompatible side effects with arguments so in this extension’s advanced options we don’t want to escape spaces, brackets or semicolons. Leave everything else as default in the advanced prefs.

5. Save, Test and we are good to go!

Click the ‘Save’ button then open Alfred and type ‘wiki bananas’, selecting the result which relates to this extension (not the default Alfred wiki result).

Hope this helps you get started with creating your own extensions!

Cheers,
Andrew
@preppeller

Note: You could achieve the above extensions with better escaping of parameters by using an AppleScript extension - possibly something for a future tumble :)

  1. blondy-butler reblogged this from preppeller
  2. istoselidon1a reblogged this from preppeller
  3. trampoline6s reblogged this from preppeller
  4. preppeller posted this