Subversion (SVN) GNOME Nautilus Script Helpers

Update, 3 November 2007:

Found a better solution: Jason Field’s NautilusSvn. More SVN features, much better integration with Nautilus, and uses emblems to show file and directory status. There is a .deb file that installed easily on my Ubuntu 7.04/Feisty Fawn machine. And it’s free as in GPL v2. Thanks, Jason!

Use NautilusSvn instead of my meager scripts!

Update, 6 November 2007:

I wrote another post about NautilusSvn and replacement emblems.

Update, 22 February 2008:

Jason’s site has been down today. Acting as a backup, here are the files I downloaded back in November:

Hopefully will be back soon and then I recommend going there for the latest and greatest.

Extend the file manager with right-click popup menu options for adding, updating, and commiting SVN files, as well as viewing log and status info.

Moraine Lake, Banff National Park, Alberta, Canada
photo by SqueakyMarmot

In Windows, I haven’t used TortoiseSVN, but I have used TortoiseCVS quite a bit. It’s a free (as in free software: GPL) Explorer shell extension that lets you manage your CVS source files from within the Windows file manager.

Along with a lot of options readily available from the popup context menu, Tortoise also modifies the file icons to show you the current CVS state; for example, a green overlaid smudge (not sure what it is offhand) to show if the file is in sync with the repo, an orange smudge if you’ve modified it since the last update, and a question mark if the file isn’t under source control. Tortoise makes it easy to use CVS for a variety of files and projects.

In Ubuntu GNU/Linux, I haven’t yet found a program that integrates handily with Nautilus (the GNOME file manager) the way that TortoiseCVS (and I imagine TortoiseSVN also) does with Windows Explorer. Often I’ll be working on the command line and can call svn easily enough, but frequently I’ll be working in the file manager and it would be convenient to interact with the source repository using a right-click and a popup menu.

So, I put together a few helper bash scripts to use with Nautilus Scripts. I wrote about these Nautilus extensions in my Free Software Magazine article: Extending Nautilus: rotating JPG images. (Also available on this web site in a single page format.) You can read the article for more detail, and also learn more at the GNOME page on extending Nautilus. I’ll assume for the remainder of this post that you are familiar with running Nautilus scripts in general, and only discuss the specifics of the SVN scripts.

Someone pointed out in the comments to the FSM article that you can use nautilus-actions as another way to customize Nautilus. Nautilus-actions is a Nautilus Extension and is mentioned on that page. Extensions are said to be more powerful than scripts, but for now I’ll stick with scripts since they serve my purposes. I have a Nautilus Scripts hammer and everything looks like a nail. I’m sure Extensions and nautilus-actions are way cool, and I’ll get to them in time. I feel compelled to keep pointing this out so as not to mislead anyone about your options.

These scripts enable a few routine actions, and are meant to be used for quick updates, adds, and commits inside already established working directories. Unfortunately, modifying icons to hint at the current state of a file is way beyond me and I’m sure beyond Nautilus Scripts. So you can’t get a lot of info at a glance like you can in Tortoise, but you can call svn status to help you out.

The tricky part for me was to figure out how to get a terminal window to display when running the Nautilus scripts. With the svn command commit, you need a way to enter a comment for your commit, and for status and log, you’ll want to see the output. For all the commands, really, you’re going to want to see the output of the command.

You can call gnome-terminal and with the -x or -e option tell it what to run, but I discovered that the terminal closes immediately after running the specified command. So I created a script that would include pauses:


# might have called gnome-terminal directly to run stuff,
# but if you give it the -x or -e option, it quits after
# running the command -- so, we'll call this script with 
# the -x option so we can have a "pause" to see the results
# of running the script

echo "\$PWD = $PWD"
echo -e "\$@ = $@\n"


if [[ $the_command != "status" && $the_command != "log" ]]; then
	read -p "press enter key to continue"

svn $the_command $@ 

read -p "press enter key to exit"

To explain, let’s first look at one of the scripts that uses It’s very simple:


gnome-terminal -x ~/.gnome2/nautilus-scripts/svn/ $the_command $@

All it does is call gnome-terminal to run, passing along our command and whatever arguments Nautilus was given. (Directories and/or filenames.) The helper script then prints out the present working directory (PWD) and the input arguments (basically, the command it’s about to run). For commands other than status and log, which might cause changes, we have a pause to give us a chance to cancel out of things with CTRL+C. After hitting enter to continue, we run the command and then have another pause to give us a chance to evaluate the results of the command. (I like the contradiction of pressing enter to exit. “The way out is the way in.”)

For the commit command, svn will start an editor to enter in your commit comment. By default I was getting Emacs (I think). I edited ~/.subversion/config to use editor-cmd = vi. There are several places that this editor setting may come from. See the free Subversion book online for more.

I won’t show the other scripts, since the only thing different between them is “the_command”, but here is a list of the ones I made for myself:

(You can download them below.) The command for is add --non-recursive, with the idea being that you might use it for adding directories without including all of the files within.

That’s all

Kind of a crude interface, I know, but it’s been useful for me.


Displaying code on an HTML page can be kind of dicey, especially when WordPress is generating the page. Please try downloading the scripts here if you have problems copying-and-pasting from above:


For these simple little scripts, I think public domain will be sufficient.


SVN helper bash script to list repository directories

2 thoughts on “Subversion (SVN) GNOME Nautilus Script Helpers

Comments are closed.