Black and White.

Wednesday, May 14, 2008

Firefox Smart Keywords

Most firefox users know about bookmark keywords - shortcuts you can assign to bookmarks so you can access them from the location bar.

For example, to add a keyword for www.slashdot.org, you’d add a bookmark with the following values:

Whenever you type /. into the location bar and hit enter, you’ll go to slashdot.org.

Old news, right? Well, I was very surprised to learn that quite a few firefox geeks don’t know about the versatility of firefox keywords - specifically, smart keywords.

The basic idea is that instead of adding a keyword for a simple URL, you add a keyword for a search box. You type the keyword followed by your search terms into the location bar, and Firefox re-writes the saved URL to perform the appropriate search on the appropriate site.

For example, say you wanted to add a smart keyword for Wikipedia. You’d right-click on the search box, and click “add a keyword for this search”.

You can make the keyword anything you like. I generally use short keywords - like w here - for sites I use a lot, as a time saver. You might also notice that I’m saving this bookmark in a folder called Searches - I find it helpful to keep all my smart-keyword bookmarks together, just for the sake of tidiness.

Now, to use your smart keyword, you simply type w foo in the location bar, where foo is your search term, and you’ll be handily redirected to Wikipedia’s article on foo.

Neat, huh?

You can add smart keywords for practically any site with a search function. I use one for Google Maps

The Wayback Machine:

And even Urban Dictionary:

If you’re browsing through some sophomoric blog comments and come across an unfamiliar term, it’s certainly a great deal quicker to type Ctrl-T Enter ud feltch Enter than it is to laboriously look up the term by hand.

But, perhaps the most interesting aspect of smart keywords is their versatility. For example, I got a little frustrated with my Wikipedia shortcut - if I misspelled the search term even slightly, I’d end up on a productivity-killing error page. For example, w the last of the mohecans would give me:

This is especially galling, seeing as a Google search for that exact term instantly recognizes what I’m looking for.

Now, this gave me a bit of an idea; why couldn’t I use Google’s search engine in a smart keyword for wikipedia?

It’s possible, but takes a little bit of tinkering. First, create a new smart keyword based around google’s search box, but give it a keyword you want to use for wikipedia.

Now, open up this new smart keyword bookmark’s properties (under Bookmarks > right click > properties). We need to edit the Location property. It should look something like http://www.google.ca/search?q=%s. There may be some other information in there - it’s not important, we’ll be replacing it in a second. The %s value is the part that is replaced by your search term when you use the smart keyword. All we need to do is add some information to tell Google we’re only interested in pages from Wikipedia, so we paste http://www.google.ca/search?q=%s%20site%3Aen.wikipedia.org&meta= into the Location box. Now, when we enter gwiki widget into Firefox’s location bar, we search google for widget site:en.wikipedia.org - every wikipedia page that contains the word widget.

We’re almost there. All we need to do now is tell Google that we don’t want to be shown a search results page, but instead we want to go directly to the first result. We do this by adding &btnI onto the end of our URL. This code tells Google we’re doing an “I’m Feeling Lucky” search. So, the final URL for our smart bookmark looks like http://www.google.ca/search?q=%s%20site%3Aen.wikipedia.org&meta=&btnI.

Blogged with the Flock Browser

No comments: