Is there a way to list the open tabs in Firefox from the command line?
5 Answers
The idea would be to access Firefox data from the 'outside'. You might want to look at Stack Overflow question How can I get list of open tabs in Firefox via a command-line application?.
-
2Ahhh - the sessionstore.js (JSON) file in your FF profile does seem to contain the appropriate list. Albeit inside a lot of noise. Seems structured enough to parse out though. Thanks for the link.– kennyCommented Apr 11, 2011 at 16:31
-
The format in latest versions is JSON compressed with LZ4 + a magic header (mozLz40\0).
This small python script will print tabs: https://gist.github.com/tmonjalo/33c4402b0d35f1233020bf427b5539fa
-
To use it in Ubuntu, you need to
sudo apt install python3-lz4– mivkCommented Nov 13, 2021 at 20:28 -
the code above works, but one may have another folder under linux, support.mozilla.org/en-US/kb/… this is a link to find a right one (originaly suggested by mwalkerr) Commented Nov 14, 2023 at 20:18
I recommend using https://github.com/balta2ar/brotab for this purpose:
pip install brotab
brotab install
Install the web extension as well: https://addons.mozilla.org/en-US/firefox/addon/brotab/
Restart Firefox, and you can run brotab commands such as:
brotab list
In Linux, you can do it with this (admittedly long) command:
lz4jsoncat $profile/sessionstore-backups/recovery.jsonlz4 \
| jq -r '.windows[] | .tabs[] | (.index - 1) as $i | .entries[$i] | .title, .url, ""'
This assumes you have set the $profile variable to your current Firefox profile with something like
profile=$HOME/.mozilla/firefox/Your_Profile
It needs the lz4json and jq packages. In Debian or Ubuntu, install them if needed with :
sudo apt install lz4json jq
According to the mozilla site, no. Command Line Options
Although you could write a plugin to write tab names to a text file I guess.
-
Thanks, I think your answer is the "right" one from a supported standpoint. But, hack > nothing.– kennyCommented Apr 11, 2011 at 18:15
-