OpenSource for work. FreeSoftware for life.

Firefox, one user, several computers, one profile per computer

This tip is for people like me who works on several computers with a simple user account.

I use to make several ssh to several computers with the same user. As my /home dir is shared and that all Firefox profiles are in ~/.mozilla/firefox, if you try to launch Firefox on both computers ... you can't

Here a simple example to better understand what I'm speaking about:

  • In two consoles, I launch two ssh with same user, but to different computers.
  • On the A computer, I launch the following command
user@machineA$ firefox /my/local/pageA.html

I've got a Firefox window on pageA.html. * On the B Computer, I do the same without closing the computer A Firefox instance:

user@machineB$ firefox /my/local/pageB.html

And now .. Firefox try to open localB.html with the Firefox instance of .. computer A

I don't care if I've got both pages on the same window, but pageB.html is on computer B not on computer A. Conclusion: Firefox doesn't find pageB.html (normal)

The solution is in the Firefox profile management. You just need to have a profile per computer.

  • First, let's creating our two profiles:
$ firefox -CreateProfile profileA --no-remote
$ firefox -CreateProfile profileB --no-remote
  • Secondly, launch Firefox using the profile corresponding to the computer:
user@machineA$ firefox -P profileA --no-remote /my/local/pageA.html
user@machineB$ firefox -P profileB --no-remote /my/local/pageB.html

Now, you've got two Firefox instance launched and you can open both pages.

To automate all this, just add the following lines to your .bashrc:

#If the profile doesn't existe create it.
if [[ $(ls ~/.mozilla/firefox | grep profile$(hostname) | wc -l ) -eq 0 ]]
then
    firefox -CreateProfile profile$(hostname) --no-remote
fi

#create an alias to launch firefox with the good profile
alias firefox="firefox -P profile$(hostname) --no-remote"

Enjoy !!

Name:
Email:
Web site:
Comment: