August 8, 2008

shortcut to launch a specific firefox profile on mac

For as long as I've been working on Mozilla projects, it's always been a breeze to create Windows shortcuts to the Profile Manager or to a specific profile. You simply created a desktop shortcut and added -profilemanager or -P name to the end of the shortcut's path.

Mac doesn't do shortcuts like Windows. While it does have aliases, you can't modify them like you can shortcuts on Windows. So, for years, I and many of my friends and colleagues working on Mozilla projects, especially the less technically savvy of us in the QA and testing community, have resorted to the tedious process of launching the Mac Terminal and typing in something like /Applications/firefox.app/Contents/MacOS/firefox -profilemanager to launch the Profile Manager. Some more savvy of the group would save some of those keystrokes by creating a shell alias for that long-ish command. Still, involving the Terminal meant moving from the mouse to the keyboard and opening and closing a second program.

Thanks to some help and inspiration from my regular Mac Hero, Eric Shepherd, I can share with you all a super-simple way to create a "shortcut" on Mac so that you can just double-click a Desktop or Dock icon to launch the Firefox Profile Manager or even a specific Firefox profile.

I'm going to use some scary (to me, at least) words and phrases but don't be turned off, it's actually really simple. We're going to write a small AppleScript to do the work that we were doing manually in the Terminal. That's it. Don't be like I was and turn away at the first mention of writing script ;-) I promise this is really, really easy.

Step 1: Open the Script Editor

If you're like me you probably haven't ever done this before, or if you did, it was an accident :-) To launch the Script Editor, simply open a Finder window and navigate to Applications -> AppleScript -> Script Editor. Double-click on the Script Editor to launch.

Alternatively, you can just hit Command+Space to active Spotlight and then type "script e" and hit Enter.

Step 2: Write some AppleScript

The good news here is that the AppleScript can actually be very simple. The even better news is that I'm not even going to ask you to write it. You just have select, copy, and paste this text into the Script Editor:

do shell script "/Applications/Firefox.app/Contents/MacOS/firefox -ProfileManager &> /dev/null &"

That's almost human readable :-) and it's pretty clear that it's simply doing for us what we used to do manually in the Terminal. The odd bits at the end are saying something like "just do what I said and don't tell me about it".

Step 3: Save your new AppleScript

Now that you've written ;-) the AppleScript, you need to save it. Select File -> Save As... and you'll be prompted with the normal options to give it a title (Save As: text field) and a location (Where: selection). I named my AppleScript "Firefox Profile Manager" and selected my Applications folder as the location.

Since we want this script to actually run when we double-click it, rather than opening back up in the Script Editor, before pressing Save we need to change the File Format from Script to Application Bundle. Don't mess with any of the Options check boxes. They're not relevant here.

Step 4: Optional Sexy

You're actually done already. You can double-click your new AppleScript Application and it will launch the Firefox Profile Manager. But there's one more step I like to do and that's to give it a better icon.

If you haven't done this before, it's really simple. Just right-click on your new Firefox Profile Manager's icon and select Get Info. Now go to your Applications folder, locate your actual Firefox, and just drag and drop the Firefox icon right on top of little AppleScript icon in the top left corner of the Get Info window. That's it.

Now you can just double-click on your sexy new Firefox Profile Manager icon and it'll start the Firefox Profile Manager. For quick access, you can drag that icon to your Dock and it'll create a nice launcher there, too.

But what if you want to bypass the Profile Manager all together? No problem!

To launch specific Firefox profiles, you can follow the exact same process as outlined above, except you'll use Firefox's Profile name option rather than the Profile Manager option. You simply paste do shell script "/Applications/firefox.app/Contents/MacOS/firefox -P name &> /dev/null &" into the Script Editor (replacing name with the actual name of your profile,) and you've got yourself a shortcut that opens Firefox with a specific profile.

I hope this helps some of you Mac Firefox users and testers out there struggling with multiple Firefox profiles.

Oh, and if you've got a better or easier way of accomplishing this, or any corrections to my instructions, please let me know in comments.

Posted by asa at 1:51 PM

 

asa2008.jpg