Fork me on GitHub

Mat Trudel


Smart Keywords are Smart

07 August 2011

Safari is a great browser, but has always had one feature missing that's present in every other modern browser: Smart Keywords. Previously I've used tools such as Sogudi or Keywurl to provide that functionality within Safari, but they were both implemented via a fragile (if awesome) hack, and as a consequence I always pointed fingers at them whenever Safari started losing its shit in the past. Happily, with the arrival of Safari 5.1, Apple has added the requisite event hooks to the extension API to enable Smart Keyword functionality as a first class extension citizen.

Smart Keywords is my implementation of Smart Keywords for Safari, using these new APIs. It's super simple (28 lines of Javascript, the majority of which is code to read & write configuration data), easily configurable, and – owing to its simplicity – should be crashproof.

To install Smart Keywords, download the extension and double click on it to install. Configuration is straightforward, and is done in the extension tab of Safari's preferences. Due to the way in which extension configurations are defined, you can define a maximum of ten keywords (this is a soft limit. If you want more, either ask me, or else fork the project and add them yourself).

To customize a keyword, enter in the keyword you want to match (say, for example 'wiki' to match searches of the form 'wiki bananarama'). When you enter this keyword in the address bar, it will be replaced with the contents of the matching URL instead, with the remainder of your query being substituted in for %s in the URL. As an example, if you have the keyword 'foo' defined with a URL of, then entering 'foo bananarama' will take you to the URL Note that spaces in your entered URL are automatically URL escaped to %20, which is usually what you want.

Comments / feedback are welcome. If you find any bugs or missing features, please let me know!