11

I would like to open a URL from the command line and have this open as a new tab or window in an already running and responding instance of Firefox. I'm using Debian's Sid branch. If I do the following:

In term 1:

$ firefox

In term 2:

$ firefox 'http://www.google.com'

Update: I've also tried -new-tab and -new-window, but I get the same result.

$ firefox -new-tab 'http://www.google.com'

I get the message:

Firefox is already running, but is not responding. To open a new window, 
you must first close the existing Firefox process, or restart your system.

This has been discussed before (e.g. here and here), however, I do not want to kill the existing instance of Firefox (it's doing just fine) and I don't want to use a different profile. This works seamlessly with Google Chrome.

oneself
  • 1,089

5 Answers5

7

Use the --new-window or --new-tab command line options:

firefox --new-window 'http://www.google.com'
firefox --new-tab 'http://www.google.com'

See https://superuser.com/questions/699127/firefox-command-line-arguments/699128#699128 and Mozilla documentation

NOTE: firefox has switched to dash-dash -- style for the command line options.

Barmar
  • 2,545
3

I have the following line in my init file:

export MOZ_NO_REMOTE=1

This effectively prevents Firefox from doing exactly what I was trying to do. Removing this fixed the problem.

oneself
  • 1,089
1

Create a file LaunchFireFox.sh with the line below:

xargs -a ff_url.txt firefox -new-tab "$line"

In a separate file ff_url.txt:

http://www.google.com

and any additional web pages.

1

If you want a new tab to open without a URL known yet, then firefox --new-tab (i.e. omitting a URL) will open a new window, which is probably not the desired behavior. Instead, use the following to open a new tab in the existing window (with the cursor set to the URL bar, so that you can enter your prompt right away):

firefox --new-tab about:newtab

This is a good command to use for a system-wide hotkey.

RimaNari
  • 193
0

For those of us using Wayland

This symptom might be due to wayland/xwayland issues (firefox's buglist).

What worked for me:

I'm running Sway, with MOZ_ENABLE_WAYLAND=1 set, and added the below to ~/.config/environment.d/<my-sway-config>.conf:

MOZ_DBUS_REMOTE=1

The above is equivalent to running the below inside a bash shell:

export MOZ_DBUS_REMOTE=1
firefox

Thereafter, all links clicked in other programs opened up in Firefox without issues. As expected. Thanks to Martin Stransky for getting me on the correct track!

x10an14
  • 101