Wednesday, December 16, 2009

Using Firefox as Eclipse's external browse

My environment for this is Ubuntu 9.10, Eclipse Galileo (3.5).
I started out thinking this would be about a one minute
configuration change. Go to Window->Preferences, click on
Web Browser, select 'use external web browser' and 'default
system web browser', done, right?

Oops, that's not quite what I want. I always already have
Firefox open and when I clicked on something that used
a browser like Help->Help Contents, it would open a new
tab in one of my existing Firefox windows instead of opening
a new browser window in the same virtual desktop as
Eclipse.

I found Mozilla Command Line Options and decided what I
needed was a command like 'firefox -new-window URL'. I
tried this at the command line and it seemed to do the right
thing - bring the URL up in a new window of the existing
browser session.

Now all I needed to do was configure this in Eclipse.
I created a new web browser (Window->Preferences,
General->Web Browser) like this:

Name: Firefox
Location: /usr/bin/firefox
Parameters: -new-window %URL%

I tried that and numerous variations. It felt like Eclipse
was just ignoring whatever I put in 'Parameters'. The URL
would always open in a new tab instead of opening a new
window.

Frustrated, I finally edited 'Firefox' to this:

Name: Firefox
Location: /home/lmulcahy/bin/firefox-new-window
Parameters:

and wrote the firefox-new-window script as follows:

#!/bin/sh
echo $@ > /tmp/firefox-new-window

I tried Help->Help Contents again and found this in
the output in /tmp:

-remote openURL(http://127.0.0.1:55895/help/index.jsp)

Well, now we're getting somewhere...
Eclipse is adding '-remote' to my command line
and it's also enclosing the URL in 'openURL()'.

To make a long story short, here's my firefox-new-window script
now. This does just what I wanted:

#!/bin/sh
URL=`echo $2 | sed 's/.*(\(.*\))/\1/'`
/usr/bin/firefox -new-window $URL

Is it just me or does this seem like a pretty gross Eclipse bug?

No comments:

Post a Comment