Tuesday, February 10, 2009

Firefox Keywords and Chrome Search Engines

In my last blog, I mentioned Chrome search engines, and how you can use them to make your address bar smarter. I had never noticed these in Firefox, but they're also there. Chrome makes them a bit more obvious (with the "Press TAB to search..." thingies), and adds them automatically for pages that you search on that are formatted in a way that Chrome can recognize, but they're there for all of us (well, except weirdos using IE or Safari; they might be there, too, but who would know?). These things are very useful if you have to poke around within a site a lot with just slightly changed URLs (I need to do this several times a day, loading different itemIDs in an author view or student preview), but they're also useful if all you want to do is search. Here's how they work.

Firefox:
  1. Create a new bookmark. It can be any page; we're going to edit it to make it what we want. Starting from Google for a Google-based keyword wouldn't be a bad idea, though, to get the favicon right.
  2. Click Bookmarks, then right click the new bookmark and choose Properties (or whatever the equivalent is on Mac).
  3. Change the Name to something to remember it by in case you need to edit it in the future, such as "Google Map Search" (or whichever one you might be setting up).
  4. Change the Location to the url you're going to search, with %s for the word or phrase you want to search on. To put that in concrete language and hopefully make it more comprehensible, let's do one of my favorites, "map" (for looking something up in Google Maps). We'll do a cooler version of this in a sec, but this is an easier place to start. For this one, your Location is http://maps.google.com/maps?f=q&hl=en&q=%s
  5. Most importantly, change the Keyword to something short to type, "map" in this case.
  6. Save changes.
Chrome:
  1. Right click the address bar, and choose "Edit search engines."
  2. Click "Add"
  3. The name, keyword, and url are the same as Firefox. The only difference is that Chrome will give you the "Press TAB" clue to let you know that you have a keyword setup with that name.
To use these things, type your keyword in the address bar, followed by your search (for example, "map 123 Fake Street, 78754". The page will load, with your search.

Note that these don't have to use search engines; any time you can fill in a phrase in a url to go to a page you're looking for, it works. It's hard to give you examples of that, since I can't show you the ones I use at work... but, well, for example, this one will load an xkcd comic by ID number:
  • keyword: xkcd
  • location: http://xkcd.com/%s
Typing "xkcd 526" in your address bar would then load one of my favorite xkcds, which you should keep around for reference.

Here are some others (note: in Chrome, I highly recommend just going to most of these pages and searching to get them into your list, and then editing the keywords; the url they grab has some extra trickiness that's neat, but I'm not going to sort out all of how those extra bits work):
  • YouTube: you, http://youtube.com/results?search_type=search_videos&search_query=%s&search_sort=relevance
  • Amazon: am, http://www.amazon.com/exec/obidos/external-search/?field-keywords=%s&mode=blended
  • IMDB: imdb, http://www.imdb.com/find?q=%s
  • Merriam-Webster: mw, http://www.merriam-webster.com/dictionary/%s
  • Allrecipes.com: cook, http://allrecipes.com/search/recipes.aspx?withterm=%s
  • Images.google.com: i, http://images.google.com/images?gbv=2&hl=en&q=%s&btnG=Search+Images
  • Maps.google.com: map, http://maps.google.com/maps?f=q&hl=en&q=%s
And this brings me to my favorite: mapto. This one is slightly trickier. The easiest thing to do is probably to search for your starting address (I have this set as my work address for my work lappy, and my home address for my home desktop) using "map YourAddress," and then copy that string into this.

Here's an example, with 1600 Pennsylvania Ave NW, Washington, District of Columbia 20006 (the White House) as our starting address:
  • Keyword: mapto
  • Location: http://maps.google.com/maps?f=d&saddr=1600+Pennsylvania+Ave+NW,+Washington,+District+of+Columbia+20006&daddr=%s&hl=en
Notice the +'s; if you're careful, you could just change that to your address. You can actually shorten that a bit; for example, this would also work:
  • Location: http://maps.google.com/maps?f=d&saddr=1600+Pennsylvania+Ave,+20006&daddr=%s&hl=en
Once you have that set up, you can type "mapto DestinationAddress" (for example, "mapto 1600 Pennsylvania Ave, 20006"), and a map from your starting address to that destination address will load.

Let me know in the comments if you have any other creative uses of keywords.

ETA: Be sure to check out the follow-up to this post, where I discover way cooler tricks.

8 comments:

João Pedro Francese said...

Wikipedia (w: http://en.wikipedia.org/wiki/%s ) is a must for me!

Your post reminded me to add YouTube and Google Images to my list. The idea for mapto is also interesting. I'll try it!

Jon Harmon said...

Sorry, Wikipedia was automatic in Chrome, so I didn't think to mention it. It's definitely a must :)

Kaushik said...

Firefox if you notice has an additional feature, you can use multiple keywords for the same search engine, clubbed with the add-on "Show Keywords 3" on firefox, it makes for a killer feature. Hope Chrome brings in something similar...

Jon Harmon said...

Sorry I took so long to reply (you probably won't see this, but in case anyone else does)... but you can assign multiple keywords to the same search engine in Chrome, it's just clunky (you have to add them as completely separate search engines). Now that extensions are close, I'm sure someone could clean that up.

Kaushik said...

Guess what I actually did :) . Thanks for the tip, only thing left now is like the Show Keywords extension, assuming I have say "dictionary1","dictionary2","dictionary3" as keywords, on entering dictionary I ought to see and be able to pick any one of them. Cometh extensions come. Any idea when they're officially going to be out?

Jon Harmon said...

There are a few sample extensions available for the dev build of Chrome, but it's hard to say how long it'll be before more extensions are possible, let alone how long it'll be before those features make it out of dev. Turnaround time on Chrome has been extremely rapid, though, so I'm hoping to see them within a couple months.

Mike Feng said...

It is actually MUCH EASIER for Firefox. Here's what you do for Google search (for example):

Go to www.google.com, right click on the search field, and click Add a keyword for this search.

Bingo. You can do this for any search field.

Jon Harmon said...

Wow, I wish I'd thought of this (via Lifehacker: You can set up a Chrome search engine to search your browser history, using chrome://history/#q=%s (for example, "h lifehacker" now pulls up all references to lifehacker in my history).