Install multiple firefox extensions

I’m a full time web developer now. Million thanks to Firefox, web development is made much much easier. To make the web development process easier, there are many many extensions.

A few of them I use for my development,

1. Firebug
2. Web Developer
3. ColorZilla
4. MeasureIt
5. ViewSourceChart
6. FireCookie
7. YSlow
8. Delicious.
9. Twitterfox
10. CSS Viewer

One problem I face when I have to work in a new machine or a new user account is installing these extensions. Not that I face this problem everyday, but this is something which is very irritating. One simple solution will be to backup the extensions folder and protect it safely, so that I can use it on any machine I use. Finally, I wrote a simple shell script which does this job.

#!/bin/bash
declare -a EXT LINK

#Let us populate the extension and the link for the extension here

EXT[0]=”ColorZilla”
EXT[1]=”Firebug”
EXT[2]=”WebDeveloper”
EXT[3]=”MeasureIt”
EXT[4]=”ViewSourceChart”
EXT[5]=”CSSViewer”
EXT[6]=”FireCookie”
EXT[7]=”YSlow”
EXT[8]=”SenSEO”
EXT[9]=”Delicious”
EXT[10]=”Twitterfox”

LINK[0]=”https://addons.mozilla.org/en-US/firefox/downloads/latest/271/addon-271-latest.xpi”
LINK[1]=”https://addons.mozilla.org/en-US/firefox/downloads/latest/1843/addon-1843-latest.xpi”
LINK[2]=”https://addons.mozilla.org/en-US/firefox/downloads/latest/60/addon-60-latest.xpi”
LINK[3]=”https://addons.mozilla.org/en-US/firefox/downloads/latest/539/addon-539-latest.xpi”
LINK[4]=”https://addons.mozilla.org/en-US/firefox/downloads/latest/655/addon-655-latest.xpi”
LINK[5]=”https://addons.mozilla.org/en-US/firefox/downloads/latest/2104/addon-2104-latest.xpi”
LINK[6]=”https://addons.mozilla.org/en-US/firefox/downloads/latest/6683/addon-6683-latest.xpi”
LINK[7]=”https://addons.mozilla.org/en-US/firefox/downloads/latest/5369/addon-5369-latest.xpi”
LINK[8]=”https://addons.mozilla.org/en-US/firefox/downloads/file/57302/senseo-0.8.9-fx.xpi”
LINK[9]=”https://addons.mozilla.org/en-US/firefox/downloads/latest/3615/addon-3615-latest.xpi”
LINK[10]=”https://addons.mozilla.org/en-US/firefox/downloads/latest/5081/addon-5081-latest.xpi”

if [ ! -d "/tmp/firefoxext-$USER/" ]
then
    echo “Creating directory in tmp”
    mkdir -p “/tmp/firefoxext-$USER/”
fi

i=0
count=${#EXT[@]}
while [ "$i" -lt "$count" ]
do
    echo “Installing ${EXT[i]}”
    filename=`echo ${LINK[i]} | awk -F “/” ‘{print $NF}’`;
    rm -rf “/tmp/firefoxext-$USER/tmp”
    mkdir -p “/tmp/firefoxext-$USER/tmp”
    
    if [ ! -f "/tmp/firefoxext-$USER/$filename" ]
    then
        echo “Downloading $filename”
        wget –quiet -O “/tmp/firefoxext-$USER/$filename” ${LINK[i]}
    fi
    
    unzip -qq -d “/tmp/firefoxext-$USER/tmp” “/tmp/firefoxext-$USER/$filename”
    fffolder=`cat “/tmp/firefoxext-$USER/tmp/install.rdf” | grep “em:id” | head -n 1 | awk -F “>” ‘{print $2}’ | awk -F “<" '{print $1}'`

    if [ -z $fffolder ]
    then
        i=`echo $i+1 | bc`;    
        continue;
    fi
    
    for j in `ls -1 "$HOME/.mozilla/firefox"`
    do
        if [ -d "$HOME/.mozilla/firefox/$j" ]
        then
            rm -rf "$HOME/.mozilla/firefox/$j/extensions/$fffolder"    
            mkdir -p "$HOME/.mozilla/firefox/$j/extensions/$fffolder"
            cp -r "/tmp/firefoxext-$USER/tmp/"* "$HOME/.mozilla/firefox/$j/extensions/$fffolder"
        fi
    done
    i=`echo $i+1 | bc`;
done

You can download the latest version of this script from here.

Logic : Download the xpi file. Unzip it. Copy it to extensions folder.

Disclaimer: Download and run the above script at your own risk. I have tested it with many cases. Worst case, this will remove all your extensions from all your profiles (OMG) (Happened to me once). Also, I would advice you not to run this script in windows. I haven’t tested it there.

Save Before Save – Gedit Plugin

A few days back, I got a mail from my friend, saying,

Subject: Versioning in Windows
Hi guys,

Does any one know a software that can version files in windows?
As simple as: There’s a certain folder of files I want to be “version” tracked, I specify the list of folders.
After this, every change I make is time-archived. So later, I can say, how did it look exactly at 3:47 am on Monday, and I get it back.

Any one has seen any s/w that can do this for me today?
Perhaps something like this, but more frequent: http://www.apple.com/timecapsule/backup.html
I remember having one like this within Google for Linux. I have a feeling they built this in the file system from scratch.

Thanks,

I replied to him about some windows software I found after some googling and also found out that there is a file system in Linux which can perform this. But changing the file system of a current system sounded “dangerous” to me. I didn’t explore much into it. I use gedit for almost all development in my machine and started wondering how hard or easy can it be to create a gedit plugin which can do this.

That resulted in the following plugin.

Installation instructions.

1. Download the latest plugin file from here.
2. Extract the files and copy the two files to ~/.gnome2/gedit/plugins
3. Open gedit and enable the plugin.
4. For the first time, configure the path where you need the backups to be stored.

TODO
1. This is a 2 hour hack. Gedit plugin’s coding convention standards (if there is anything) is not followed.
2. The time taken to save might increase if there are too many backup files. //TODO for next version.
3. A neat GUI to show the diff and all the saved versions in the backup folder.
4. An option to save diffs or the full text.
5. Format of the filename can be provided as an option to the user.

Hope you like the plugin. Please fill in your feedback as comments to this post.