2

How can I restart Firefox from the command-line and restore the previous state completely (or as much as possible) after restart? Sure, I can do something like killall firefox; firefox, but that would not restore the session.

5 Answers 5

5

You can set Firefox to open with the previously open windows & tabs. It should be under Preferences -> General -> "When Firefox starts". Set that to "Show my windows and tabs from last time":

enter image description here

You should now be able to restart firefox with killall firefox; firefox & and have the same session.

5

I think you need to do a setting in firefox before you restart it from command line. Go to:

   Prefrences->General->When Firefox starts

and select :

   Show my windows and tabs from last time

then from the command line , restart it the way you like ( may be killall firefox; firefox&) and you ll get the desired result.

For more advance tuning about session restore you can type about:config in address bar and search for session or restore to change it.

https://support.mozilla.org/en-US/questions/1089103#answer-794586

1
  • The 'show my windows and tabs from last time' setting has been renamed to 'open previous windows and tabs' (about:preferences#general)
    – user598527
    Commented Apr 27, 2022 at 13:50
2

If you desire to restart Firefox with two or more profiles, this Bash script appears to work consistently:

#!/bin/bash
killall -s SIGTERM firefox; sleep 60
firefox -P "user" &
firefox -P "default settings" &

Replace the quoted profile names with your own (see about:profiles). Use the -foreground flag to control which windows appears on top, if desired.

As noted by the other answers, enable the 'open previous windows and tabs' setting in the preferences (about:preferences#general)

The value in sleep 60 (seconds) can potentially be lowered.

2
2

Unfortunately, there's no easy way to accomplish this. The closest thing to it would actually be using the Firefox Console (Shift + F2) and typing in restart.

Firefox Console restart function

Aside from that, one could install an Addon or take @terdon's advice in his answer and change Firefox Preferences to "Show my windows and tabs from last time" When Firefox starts and "restarting" with

$ killall firefox; sleep 1; firefox &

UPDATE: The "gcli" was removed from firefox in 2018. Therefore, the "Shift+F2" shortcut no longer works.

0
1

As of 2020, edit advanced settings via about:config, search for resume and set the browser.sessionstore.resume_session_once flag to true, then exit.

Here's documentation on the flag: https://kb.mozillazine.org/Browser.sessionstore.resume_session_once

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .