Start with Firefox version 13, the --new-instance
switch is added. It is better to do it this way, with the help of a bash script:
firefox -P <profile_name> -remote "ping()" || firefox --new-instance -P <profile_name> <url> && firefox -P <profile_name> -remote "openurl(<url>,new-window)"
Changing from new-window
to new-tab
will cause the URL open in a new tab in profile instead.
Break it down:
firefox -P <profile_name> -remote "ping()"
does the running instance check.
|| firefox --new-instance -P <profile_name> <url>
double pipe ||
means if the check fails, it will start a new instance with given profile.
&& firefox -P <profile_name> -remote "openurl(<url>,new-window)"
and of course, &&
means, if the check succeeds, it will re-use the existing instance to open the URL in a new window.