5

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.

  • 1
    If Firefox is your default browser, you can use xdg-open, which opens any file with its associated application. – AFH Oct 20 '14 at 19:23
4

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

  • 2
    Not sure why, but I get the same result with -new-tab/-new-window. – oneself Oct 20 '14 at 20:21
  • Maybe you have a preference setting that conflates them. – Barmar Oct 20 '14 at 20:22
  • I tried moving the ~/.mozilla dir out of the way and have Firefox recreate the default config. Same behavior. Are there any other settings that might influence this behavior? – oneself Oct 20 '14 at 23:32
  • I think I discovered the culprit. I have MOZ_NO_REMOTE=1 set in my init file. Removing this fixed the problem. Thanks for your help. – oneself Oct 20 '14 at 23:38
  • 1
    careful with the long options: they start with two dashes, such as: --new-tab – woohoo Mar 1 '15 at 16:30
2

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.

  • 2
    What is the init file you are referring to? Thanks. – Nabil Kadimi Oct 5 '15 at 8:57
  • 1
    Note that setting export MOZ_NO_REMOTE=0 instead is a wrong track, since both lines are synonyms. I got messed up with that XD – iago-lito Sep 20 '18 at 11:38
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.