This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Tools & Utilities

Doing a diff without touching the command line

By Ben Martin on November 19, 2008 (9:00:00 AM)

Share    Print    Comments   

With diff-ext, GNOME users can compare and merge files from within Nautilus. If, instead, you use KDE 3, try out kdiff-ext from the same site, which works with Konqueror. Each utility handles paths to files and directories and invokes an external diff tool to perform the grunt work. With diff-ext you can easily compare two files with different names, from different directories, or whole directory trees.

Among the major Linux distributions, the only package I could find was gdiff-ext for Ubuntu Intrepid. I'll build the program from source using version 0.3 of gdiff-ext on a 64-bit Fedora 9 machine. At the time of writing the downloads page erroneously listed 0.2.4 as the latest version of gdiff-ext. You might like to click on the "Older versions" link at the bottom of the project's SourceForge.net page to investigate what releases exist for download to verify the latest version.

To build gdiff-ext you'll need to have nautilus-devel installed on Fedora 9 or openSUSE 11. On Intrepid you'll want libnautilus-extension-dev installed. Then run:

$ tar xjvf /FromWeb/gdiff-ext-0.3.tar.bz2 $ cd ./gdiff-ext-* $ ./configure $ make -k ... make[3]: Entering directory `/home/ben/gdiff-ext-0.3/diff-ext/src' ... -fPIC -DPIC -o .libs/main.o main.c:16:25: error: gconf/gconf.h: No such file or directory main.c:17:32: error: gconf/gconf-client.h: No such file or directory main.c:18:41: error: libgnomevfs/gnome-vfs-utils.h: No such file or directory ...

It is a shame that the gdiff-ext sources have become a little convoluted to build from, but it's nothing that a new release couldn't fairly easily clean up. To get around what appears to be an issue finding your GConf development files, you can try exporting some additional GNOME libraries into your CFLAGS, as shown below.

$ export CFLAGS=`pkg-config gnome-vfs-2.0 eel-2.0 --cflags` $ ./configure $ make ... make[3]: Entering directory `/home/ben/gdiff-ext-0.3/setup/src' ... main.c:17:37: error: eel/eel-mime-extensions.h: No such file or directory main.c: In function 'main': main.c:116: warning: initialization makes pointer from integer without a cast

To get around the above compile issue in setup/src involving the eel library, copy eel-mime-extensions.c/eel-mime-extensions.h from eel-2.20.0 to setup/src and edit main.c to include the header and source file from the current directory. The eel-mime-extensions files were removed from libeel in October 2007.

$ vi setup/src/main.c #include <libgnomevfs/gnome-vfs-mime-info.h> #include "eel-mime-extensions.h" #include "eel-mime-extensions.c" $ make $ sudo make install

Once everything completes successfully you will have to restart Nautilus for it to notice gdiff-ext. If your GNOME environment is set up to respawn Nautilus, you can send kill all your Nautilus processes and have it respawned. The last step is to start gdiff-ext-setup to make sure that your favourite diff program is run by gdiff-ext.

$ killall -15 nautilus $ gdiff-ext-setup

Now you should be able to select two files in a directory in Nautilus, right-click to bring up the context menu, and notice a Compare entry toward the bottom of the menu. Selecting Compare will run your preferred diff utility on these files as shown in the adjacent screenshot.

If you have only a single file highlighted and bring up the context menu you will see "Compare later" in the context menu. Selecting that option places the path of the selected file onto a stack. The next time you select a single file you will see both "Compare later" and "Compare to '/.../first-file'" in the context menu.

If you select two files, you will be able to compare those two like before, but also have the option to run a three-way comparison with a file from the "Compare later" stack. Although I mention a compare stack, currently gdiff-ext only lets you compare with the very last thing you added to the "Compare later" stack.

If you select two directories and choose Compare, then both directories are passed to your nominated diff tool. For example, using Meld as I did during testing a recursive diff between the two directories is shown.

The project provides documentation for gdiff-ext but nothing for kdiff-ext.

Having diff-ext available in your file manager gives you great flexibility in running diff on files in different locations. If you have a large display with many file manager windows open at once, you might actually be able to start a diff quicker with the mouse than in a terminal window.

Ben Martin has been working on filesystems for more than 10 years. He completed his Ph.D. and now offers consulting services focused on libferris, filesystems, and search solutions.

Share    Print    Comments   

Comments

on Doing a diff without touching the command line

Note: Comments are owned by the poster. We are not responsible for their content.

Doing a diff without touching the command line

Posted by: Anonymous [ip: 24.131.41.49] on November 19, 2008 12:34 PM
apt-get install tkdiff

#

Doing a diff without touching the command line

Posted by: Stuart on November 19, 2008 01:11 PM
Another nice alternative is kdiff3, which is included in the major linux distros.

#

Debian Testing

Posted by: Anonymous [ip: 72.229.31.227] on November 19, 2008 04:19 PM
Debian Testing, and Sid both have diff-ext.
try out kdiff-ext from the same site, which works with Konqueror
This one is not present, however, kdiff3 works just as well with Konqueror.

#

Doing a diff without touching the command line

Posted by: Anonymous [ip: 24.31.187.238] on November 19, 2008 08:35 PM
There's a certain irony that the title of this article is "Doing a diff without touching the command line", and yet the author spends a huge chunk of the article on just compiling the program from the command line.

I know that different distros use different package systems, but still, the best command-line-less visual diff program I know of is meld (via synaptic).

#

Re: Doing a diff without touching the command line

Posted by: Anonymous [ip: 208.67.191.194] on November 19, 2008 11:52 PM
The program he's talking about doesn't even do the diff itself, it's just a nautilus extension to launch a separate diff program (like meld which is awesome).
I think it could've been dones simpler with a python/perl/bash+zenity script via the built in nautilus extensions.

#

Doing a diff without touching the command line

Posted by: Anonymous [ip: 76.67.176.190] on November 20, 2008 12:44 AM
this is confusing, he keep talking about gdiff-ext in interpid. there is no such thing. it's called diff and diff-ext. that's all! and what's with the compiling from source? why did you do that ben? is something wrong with the package in the repo? are you trying to school us somehow? because i just got the diff packages you were trying to talk about through synpatic and now i have the Meld diff viewer.

all that *gasp* without openinig the terminal.

it's just annoying when people are trying to show you something and decide to compile from source "just because". because of what?

#

Re: Doing a diff without touching the command line

Posted by: Anonymous [ip: 24.196.83.102] on December 17, 2008 06:26 PM
can you select files in nautilus and have them open meld? multiple files from different folders too?

this is what gdiff-ext provides, it's just a little bit more useful than just using meld.

#

Doing a diff without touching the command line

Posted by: Anonymous [ip: 83.49.175.14] on November 20, 2008 11:10 AM
In (K)Ubuntu 8.10 (Intrepid) there's no kdiff3, it has been superseded by Kompare

http://www.caffeinated.me.uk/kompare/

As you can see, clearer

#

If you don't mind touching the command line

Posted by: Anonymous [ip: 67.188.65.149] on November 20, 2008 11:26 AM
Try sdiff

http://www.oreillynet.com/linux/cmd/cmd.csp?path=s/sdiff

I use it all the time. I find it better than standard diff.

#

Doing a diff without touching the command line

Posted by: Anonymous [ip: 38.104.156.10] on December 03, 2008 04:09 PM
A similar thing can be done with Diffuse 0.2.15. Right click on some files in Nautilus and choose 'Open with "Diffuse Merge Tool"'. Diffuse will compare the files with their base revisions.

http://diffuse.sourceforge.net/

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya