Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

What is the command line to show the list of all installed extensions on the firefox browser? Is there any. I checked man firefox but did not help.

share|improve this question

2 Answers 2

up vote 10 down vote accepted

Give a try to this grep oneliner command to list all the firefox addons,

grep -oP '(?<=\},\"name\":\")([^"]*)' ~/.mozilla/firefox/*.default/addons.json

OR

This worked for me:

user@host:~$ cat ~/.mozilla/firefox/*.default/addons.json |
python -c 'import json,sys;obj=json.load(sys.stdin);
for (i, x) in enumerate(obj["addons"]):
  print x["name"]' | uniq

Output in my case:

Clean Links
Tee-Timer

Explanation:

  • cat ~/.mozilla/firefox/*.default/addons.json: reads the addons.json file in each profile.
  • python -c 'import json,sys;obj=json.load(sys.stdin); load the json parser library of python and loads json via stdin (standard input), ergo from cat
  • for (i, x) in enumerate(obj["addons"]): phyton code to loop through the array of addons...
  • print x["name"]' | uniq ...and print its name only one.
share|improve this answer
    
OMG, would please put some description on them –  lion Jun 20 at 7:06
    
@alex see my edit –  chaos Jun 20 at 7:12
    
This is very good (+1) but needlessly complex. You don't need to escape the " in your regex and you also don't really need the lookbehind. There is no guarantee that the home dir will be /home/$(whoami) it could be anywhere. A better approach would be to use ~/ or $HOME. There's no point in finding the default profile name either. It will always end in .default and even if there are more, you can parse all of them and pass through uniq. The USER=user is pointless, there is already a global variable called USER that holds your username. –  terdon Jun 20 at 9:40
    
@terdon good points, thanks. I edited the answer again... –  chaos Jun 20 at 9:49

This is basically just a simplified version of @chaos's approach:

grep -oP '},"name":"\K[^"]*' ~/.mozilla/firefox/*.default/addons.json

There's no reason to get the name of the user, you can always just use ~/ or $HOME to get the home directory. The name of the default profile is, likewise, unneeded. You probably only have one and its name will be RandomString.default. If you have more than one, and different addons for each, this approach will list all of them. So, if you do have multiple profiles, you might want to add | uniq to the above command to remove duplicates.

Explanation

  • grep -oP : the -o causes grep to only print the matched portion of the line and the -P activates Perl Compatible Regular Expressions which are needed for the \K (see below).
  • },"name":"\K[^"]*: match the longest stretch of non-" characters ([^"]*) that come right after },"name":. The \K means "ignore everything matched up to here" which, when combined with -o, will cause only the part of the match after the name:":" to be printed.
  • ~/ : this is your home directory.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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