Multiple Firefoxes

July 8th, 2009

2011-9-15 Update – see below

Firefox 3.5 officially came out a few weeks ago, and I decided its time to try it out.  However, google gears does not yet work on 3.5, and I need my gears to have offline access to gmail and google docs.  Time to revisit the question I’ve had many times before –

Can i run different versions of firefox at the same time?  or different instances of the same version?  … Yes.

The solution involves Firefox Profiles.  Profiles are separate from the application itself – it’s where all your customized data is stored, like homepage, history, saved form info, settings, plugins, etc.  In order to run 2 firefoxes at the same time, you need 2 different profiles.  It doesn’t matter which version of firefox is running a profile. For example, you could have 4 profiles like me:

  • Firefox3.0 – google gears in here – use this for offline gmail access
  • Firefox3.0_heavy – firebug and other add-ons in here
  • Firefox3.5 – surf the web from here
  • Firefox3.5_Guest – clean empty profile with no history, used in business meetings

Firefox has good instructions on creating profiles, so I’m going to skip that.  Next step is to figure out a way to easily launch your profiles – here is where it gets into MAC only mode, but not much different for Windows.  If you only have one profile for each version of firefox, you can edit the files inside the firefox app directly, like Devon did. (Another way is to create an application bundle). So what happens if you want to run 2 instances of the same firefox version?  Well, expanding on Devon’s way, just create a script (executable text file) in your /Applications folder that calls the firefox version and profile you want.

However, neither Devon’s solution nor the application bundle is perfect – there are still some dock issues.  First, with both solutions, there will be an icon that launches firefox with your favorite profile, and when you click on it, it creates another firefox icon on the doc.  Ideally it should act like finder or any other mac app – the icon you click on the dock is the one that should bounce and start up.  It should also be the one to right click and “Quit”.   Its confusing enough already when there’s 2 firefox apps running, i don’t need extra icons.  Second, I’m also a big fan of switching between my running applications using Command-Tab (like Alt-Tab in Windows), and when I do that I want the names of the different firefoxes to match to profiles and versions if possible.

So my solution is to have a one-to-one mapping of application name to profile name.  For example, given the 4 profiles above, I have 4 copies of firefox in my applications folder

  • /Applications/Firefox3.0.app
  • /Applications/Firefox3.0_Heavy.app
  • /Applications/Firefox3.5.app
  • /Applications/Firefox3.5_Guest.app

Each one of these I edited the Contents/MacOS directory, renaming firefox-bin to firefox-bin1 and creating a firefox-bin script (like Devon did).  Each script is uses its own directory and profile. For example, here’s the contents of my /Applications/Firefox3.5.app/Contents/MacOS/firefox-bin file:

/Applications/Firefox3.5.app/Contents/MacOS/firefox-bin1 -P Firefox3.5 &

The last thing I do to make it easy on myself is to create a bookmark on the toolbar, all the way left on each of the 4, where the name of the bookmark is the name of that profile.  That way I can look at the window and know which firefox profile i’m using.

The downside to this is that you waste some disk space (its about 50MB for each firefox installation).  The other thing that kinda sux is that if you rely on firefox to remember password forms, you must remember to always use the same profile/app, but that isn’t hard if you do my bookmark trick.

Update 11/2: Here’s how I handle firefox updates (like from 3.5.3 to 3.5.4).

Basically i reinstall my fix after update.  That is, rename firefox-bin to firefox-bin1, then create firefox-bin script.

However, This used to work but today it no longer does.  Basically if i call firefox-bin1 -P Firefox3.5 from cmd-line, it works.  But the app uses the default profile instead.   My workaround is to create and use “application bundle” method linked above. still testing …

Others attempts (but no mention of my dock issue)

  • http://67central.com/bc/2009/02/07/single-purpose-web-dev-browser/
  • http://stackoverflow.com/questions/730748/how-to-change-the-executable-in-an-os-x-application-bundle
  • http://weblogs.mozillazine.org/asa/archives/2008/08/shortcut_to_lau.html

2011-9-15 Update – New method

With firefox 4, 5, 6 … Firefox is clearly updating more and more frequently.  My new method is to make it easy to update the main app to the latest Firefox version, yet still keep the profiles separate (cookies, add-ons, etc).

Therefore I create 2 types of apps.  The first is just the app downloaded from firefox, copied from the .dmg file.  I rename this to something like Firefox6.app.  The second type of app is one made for the dock, which will launch Firefox6 with a specific profile.  I call this FF6.app and create it using Applescript.  If you don’t know applescript, there are many sites that explain it, here’s one the talks about creating applescript and saving as an app (more).

Here’s what my applescript code looks like for FF6.app

on run {input, parameters} 
do shell script "/Applications/chad/Firefox6.app/Contents/MacOS/firefox-bin -P firefox6 &> /dev/null &"
return input 
end run

Note on changing the icon – Open finder, right click on an application or document, and “Get Info”. By selecting the icon in the “Get Info” window, with a mouse left-click, it will cause a blue border to appear. Using the keyboard combination of [Apple Key ] + C (the standard copy text command) you can “copy” the icon. Then, by opening another Get Info window and highlighting the icon in the same way, you can use the standard paste text command, [Apple Key ] + V, to paste the icon for the other one.