33

I'm trying to open firefox with two tabs from the command line, with two separate web addresses. So far I'm having no luck.

firefox -new-tab https://www.evernote.com/Home.action -new-tab http://www.gmail.com

Could someone point me in the right direction?

muru
  • 207,970
Andy J
  • 1,137
  • 1
  • 13
  • 19

4 Answers4

37

Oops. I just found the answer. You need to add a -url after each `-new-tab'.

firefox -new-tab -url https://www.evernote.com/Home.action -new-tab -url http://www.gmail.com

Now it works. Hope this can help somebody.

muru
  • 207,970
Andy J
  • 1,137
  • 1
  • 13
  • 19
15

You no longer need to add -url, simply write firefox followed by space-separated URLs.

Example:

firefox mail.google.com askubuntu.com stackoverflow.com
  • This is a nice solution. Personally, I run it at startup using CTRL+R to recall the line and with a & at the end of the command to detach the firefox session from the terminal - just a suggestion. – somethis Aug 07 '19 at 09:38
  • 1
    This is not working for me. The only change that I did was that I have added a new profile in firefox and set it as the default. Now when I try the above solution, I get the following error

    Firefox is already running, but is not responding. To use Firefox, you must first close the existing Firefox process, restart your device, or use a different profile.

    Firefox is not stuck though. Both the new profile and the default one are working fine from the UI.

    – livinston Mar 02 '21 at 03:28
8

Create a file containing list of URLs called url.txt:

http://www.url1.xxx
http://www.url2.xxx
http://www.url3.xxx

Firefox uses the new-tab command, so you could pass the URLs in the file to the browser like so:

xargs -a url.txt firefox -new-tab "$line"
muru
  • 207,970
Maythux
  • 87,451
  • @Maythus awesome – alhelal Jul 19 '16 at 09:41
  • this approach generates the same popup error cited by @livinston – user2901351 Jan 19 '22 at 17:46
  • this approach generates the same popup error cited by @livinston

    additional info: I am using firefox 96. This issue only appeared somewhere after version 90 (or with whatever ubuntu 20.04.3 updates were made in this timeframe). Not clear to me if this is a firefox issue or an ubuntu one, but the fact that I get the same error when running the equivalent command for vivaldi, brave, and opera makes me think is an issue brought upon us by GNOME or ubuntu.

    https://askubuntu.com/questions/1374403/after-firefox-94-update-cli-launch-half-broken

    – user2901351 Jan 19 '22 at 18:40
0

If you have a file tabs.txt with a URL on each line, you can use this command:

firefox $(cat tabs.txt) &

and it will open an instance of Firefox and a tab for each line.

Added the ampersand so it can run as a separate process.

To save the tabs, I am using a Firefox extension that copies the tabs to the clipboard. I save them in Documents to open later.

Pablo Bianchi
  • 17,552