By John Gruber
Discover fractals and create your own fractal art with Ultra Fractal.
I’ve mentioned before that one of my favorite improvements to Snow Leopard was the overhaul of the system-wide Services menu. Service menu items are more easily accessed (including via the system-wide contextual menu), keyboard shortcuts are now easily configurable, and, best of all, you can easily create your own services using Automator and scripting languages like AppleScript, Perl, Ruby, and Python. Here’s a good overview of Snow Leopard services from Sal Soghoian.
I’ve written a bunch that I use personally. One of my most-used is called “Open URLs in Safari Tabs”. Here’s how it works:
The most common app from which I use it is Mail. Say someone sends me an email with three URLs, and I want to open all three of them. The typical way is to click one, which opens it in Safari and brings Safari to the front, then switch back to Mail and click the next one (which again brings Safari front), then switch back to Mail again and click the last one.1
With this service, I just select a range of text in the message that includes all three URLs, control-click on the selection, and select “Open URLs in Safari Tabs”.
URLs are identified using the regex pattern I posted last week.
I wrote the script so that Safari doesn’t come to the front when the service is invoked — the new window and tabs are created in the background. (If you’d rather have Safari come to the front, there’s a line in the script you can uncomment.)
The service should now be available system-wide, both via the contextual menu and the Services sub-menu in the Application menu, when the current selection is a range of text. You can set a keyboard shortcut for any service in the Keyboard panel of System Preferences. If you wish to examine how it works or change its behavior, open it using Automator.
The service only works with Safari (and WebKit nightlies); it doesn’t work with other browsers such as Firefox or Chrome. The version I’ve made available for download requires Mac OS X 10.6 (Snow Leopard) or later; if you’re using 10.4 or 10.5, you can create a service based on the below-linked Perl script using Jesper’s free ThisService utility.
Mac OS X Mail supports a shortcut for opening links in the background: Command-clicking; if you know this, you can save a few steps. ↩︎