Ubuntu Firefox/Chrome handle svn protocol

If you're using using a web-based bug tracking system (in my case, JIRA), or getting Subversion check-in emails in a web-based client, you may have seen URIs like this:


This is basically a link to your Subversion server, a particular file and a particular revision (26981). Wouldn't it be nice to be able to click on that link and have the diff open up? Firefox can be configured to handle the URI with a specific external application, but I could not find any such application for Ubuntu.

Enter the custom BASH script:



  echo -e "$(sed 'y/+/ /; s/%/\\x/g')"

urlDecoded=`echo "$1"| urldecode`

if [[ $urlDecoded =~ $regex ]]; then

        # the sed command is a quick and dirty URL decode

        svn diff "$url" -c $revision --diff-cmd $diff

        echo "Can't parse svn URI"

This script parses out the revision number, calls the Subversion command-line tool to create a diff, and open the diff in Meld. Obviously, you need Subversion and Meld installed. Once saved as "svnhandler.sh", and made executable via "chmod +x svnhandler.sh", you can call it on the specific URI:

./svnhandler.sh svn://sourcecontrol:3690/MAINLINE/release_1.3/java/com/bitkickers/somefile.java#26981

You should end up with a Meld screen that looks like this:

To get Firefox to pass this URI to the BASH script, you need to open a new tab and go to "about:config". Then right-click in the grid, and select "New" to add the following two settings:

  • String
  • network.protocol-handler.app.svn
  • /home/chase/bin/svnhandler.sh
  • Boolean
  • network.protocol-handler.external.svn
  • true

If you search for "svn", you should see the following:

Now, that didn't quite work on its own for me. I had to go into Edit -> Preferences, Applications, filter for "svn", and then set the handler again there.

Edit: updated regex to support "svn://...?r=123" syntax as well.

Edit: You can also add this script as the default URL handler in Gnome, which is also what Google Chrome will use to open the link.

gconftool-2 -s /desktop/gnome/url-handlers/svn/command '/path/to/script/svnhandler.sh %s' --type String
gconftool-2 -s /desktop/gnome/url-handlers/svn/enabled --type Boolean true

I'm currently working at NerdWallet, a startup in San Francisco trying to bring clarity to all of life's financial decisions. We're hiring like crazy. Hit me up on Twitter, I would love to talk.

Follow @chase_seibert on Twitter