Safari is a great browser, but it's search box is a bit limited. By pointing it to a relatively simple script, you can add keyword searching and make your life a bit easier.
Customizing where your searches in Safari actually go takes a few relatively simple changes. "Relatively" is the key word here -- the changes aren't too complex, but they do involve mucking around with some system files, which means you need to be really careful while doing this. It should work out just fine, but remember, you're doing this at your own risk, and I'm not responsible if things go wrong.
Instructions
- Make a copy of
/Applications/Safari.app
and store it somewhere safe. - If Safari is running, Quit it.
- Open up
/Applications/Safari.app/Contents/MacOS/Safari
with a hex editor (may I recommend Hex Fiend?). - Search for this URL in the file:
http://%@.google.com/%@?q=%@&ie=UTF-8&oe=UTF-8.%@&cat=%@
. In Safari 3, this occurs at offset 1,125,084. - Replace the URL with
file:///Users/YOUR_NAME/Sites/s.html?%@=%@&q=%@&z=%@aa%@
, substituting your username where it saysYOUR_NAME
. The replacement URL has to be exactly the same length are the one you're overwriting -- 56 bytes -- so adjust the number ofa
s near the end to compensate. This is really important! - Download s.html and put it in your Sites folder.
This gives you the following keywords:
- a: Alias of amazon
- amazon (query): Searches Amazon.com
- define (word): Looks up the given word on Dictionary.com
- imdb (query): Searches IMDB.com
- img (query): Searches Google Images
- php (query): Searches the documentation for PHP
- vt (query): Searches VersionTracker.com
- w: Alias of wiki
- wiki (page name): Goes to the given Wikipedia page
- yahoo (query): Searches with Yahoo.com
If you don't enter a keyword, a normal Google search is performed, just like before. You can add your own keywords just by editing s.html -- it's pretty straightforward.
Boring Background Story
When I first switched to the Mac, I was really excited about using Safari -- it looked so sleek and speedy. I loved Firefox, but platform integration was too hard to resist. However, I quickly found one feature in Firefox that I absolutely couldn't live without: search keywords. This handy little feature lets you make a keyword for any search field you find online, after which you can type
<keyword> <search terms>into the address bar and do a search. For example, going to
wiki nerdwould search Wikipedia for nerd. It was awesome.
Safari had a Google search field built in, which was good, but not perfect. I did some Googling and discovered a technique for changing the search engine, and came up with this little hack.
Feedback
If you have any comments or suggestions, I'd love to hear them -- drop me a line.