Sunday, June 26, 2011

Open links from external applications in a new window in Google Chrome on Mac OS X

I love tabbed browsing. I switched to Firefox way back in the day partially because Firefox allowed tabbed browsing. I recently switched to Google Chrome, which also has tabbed browsing.

I also love virtual desktops. I switched to Linux on the desktop way back in the day partially because it supported virtual desktops. I currently use Mac OS X which has "Spaces", so I continue to have virtual desktops.

However, when you combine the two, you potentially have a problem. If you have a web browser open, but it is not on your current virtual desktop, and you click on a link in a different application (a newsreader, perhaps), do you want that external link to open in a new tab in an existing browser window on a different space, or do you want it to open a new browser window on your current space, and open the link in a new tab on that new window?

Turns out lots of people prefer the second option - they want a new window on their current space with the link opened in it. Now, adults may disagree, and Firefox as well as Safari have a preference setting which allows you to change the behavior to either of those options. Everyone's happy.

Except Google Chrome users. Chrome always opens external links in the most recently used browser window, where ever it is.

This causes some people to be upset, example: http://www.google.com/support/forum/p/Chrome/thread?tid=1eb2eb870ba29e97&hl=en


I was also upset. I am a programmer though, and I can make the computer do what I want normally. So I made it do what I want.

1) Download this AppleScript bundle, and unpack it in ~/Library/Scripts/
2) Double-click it (to register it with Launch Services)
3) Open Safari and go to the General tab in the Preferences, and set your app as the default browser.
4) Share and enjoy

A fair bit of credit for making this work goes to Pepjin de Vos - http://pepijndevos.nl/2010/05/open-external-links-in-running-browser/ - I repurposed his idea/script to implement my workaround here.