Open all your browsers at once in OSx

Here's how to go about opening all your browsers at once

So here is the problem, you have one browser that you want to spend most of your day in, this will be Firefox or if you are a lesser being Chrome or Opera or something, but when you want to test your web-thing in various browsers, go and manually open them up.

Manually doing stuff is boring so I wrote a quick function to open up all the browsers at once from another application that I spend all day in, the Terminal.

Without further ado here is the code;

function browser() {
    /Applications/Firefox.app/Contents/MacOS/firefox $1 < /dev/null >&/dev/null &
    /Applications/FirefoxNightly.app/Contents/MacOS/firefox -no-remote -P nightly $1 </dev/null &>/dev/null &
    /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome  $1 </dev/null &>/dev/null &
    /Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary $1 </dev/null &>/dev/null &
    /Applications/Opera.app/Contents/MacOS/Opera $1 </dev/null &>/dev/null &
    /Applications/Opera\ Next.app/Contents/MacOS/Opera $1 </dev/null &>/dev/null &
    /Applications/Safari.app/Contents/MacOS/Safari $1 </dev/null &>/dev/null &
    /Applications/Webkit.app/Contents/MacOS/Webkit $1 </dev/null &>/dev/null &
}

Here are a few notes about the code;

  • This is geared up for my system, if you have called your browsers something different you will need to edit them.
  • This is opening up the following browsers - Firefox, Firefox Nightly, Google Chrome, Google Chrome Canary, Opera, Opera Next, Safari and Webkit Nightly
  • I had to do some external setup to get Firefox and Firefox Nightly working together (more on that in a second)
  • If you pass in a URL when calling browser it will open the browsers with that URL

This creates a function you can call from the command line called browser, this function will run each line in turn. All each line does is open the binary stored within your .app folder.

The </dev/null &>/dev/null & part of the line simply says to the terminal, don’t bother me with any output from these browsers, it effectively detaches them from the terminal.

To ‘install’ this script you should edit your .bash_profile, you can do this by calling vi ~/.bash_profile and copying the above script into it.

Once you have copied it in you will need to force your terminal to read the update file, you do this by running source ~/.bash_profile

Now you can call the script whenever you want from your terminal by typing browser www.mysite.com

Firefox

OK so you aren’t meant to have two Firefox profiles running at once so what I had to do is run Firefox Nightly using a separate profile, this is pretty easy to setup.

Create a new profile, you can do that by running the following command;

/Applications/Firefox.app/Contents/MacOS/firefox -CreateProfile nightly

This will create a new profile called nightly, then you can associate that profile with Firefox Nightly as I have done above.

Resources

I had to use some other articles during research for this bit of code and I couldn’t have written it without them!

If you need to download any of the browsers mentioned, here you go!

And last but not least, this was inspired by a talk Paul Irish gave, you can view it here.

Recent posts View all

MacProductivity

Some Mac Tips

Some settings or tips I've learned over the years to make using your Mac an even nicer experience

Writing Git

How to speed up Rubocop

A small bit of config that could speed up your Rubocop runs