9

I have installed meld in Ubuntu 10.10. Is there any way I can get something like "Select left to compare" and "Compare with" context menu for files that is there in Beyond Compare.

Nemo
  • 191

8 Answers8

10

Here's a slightly different approach that works great for me. (I'm using Nemo on Ubuntu 13.10).

  1. Select two or more text files (any extension. Say foo.php , bar.py, abc.txt)
  2. Right click on them. Goto properties.
  3. Under the "Open With" tab. Select "Show other Applications".
  4. Select Meld from the list and Add. (Don't make it the default application)
  5. Close the dialog box.

From now on, whenever you need to compare 2 or more files, select the files, right click on them, and select 'meld' listed under "Open With". Meld will open with the diff.

I dig this setup. Keeps the Right click context menu cleaner and also gets meld working from inside Nemo, without installing anything new.

Caveat: Doesn't work for folders. However, comparing folders is anyway a rarely used action. I'm happy to use the Terminal for doing that. i.e. by doing this from the shell prompt: meld folder1 folder2

P.S. -- This trick is also great for setting the default applications to be used for opening different types of files.

8

Install Nautilus actions.

sudo apt-get install nautilus-actions

System > Nautilus Actions

Define new action:

Label: Meld..
Icon: /usr/share/pixmaps/meld.png
Path: /usr/bin/meld
Parameters: %M
Conditions : check “Appears if selection contains”    

Then restart nautilus

nautilus -q
thegreendroid
  • 255
  • 4
  • 8
3

Here is an updated version of @darthvader's answer for Ubuntu 13.10 with screenshots:

Install Nautilus Actions and open the application.

Under the Action tab, use the icon path: /usr/share/app-install/icons/meld.svg

enter image description here

Under command, use meld with %F

enter image description here

And under the environment tab, set the Count to be strictly greater than 1.

enter image description here

Mendhak
  • 158
2

If you use Thunar file manager, then:

Works comparing files and also comparing directories. I have spanish version, sorry :)

1) Open Edit > Configure custom actions:

enter image description here

2) Click on Add icon (the green plus one)

enter image description here

3) Fill the form...

enter image description here

enter image description here

4) Accept and check the result...

enter image description here

5) Finish!

enter image description here

2

What I like to do is:

  1. add two thunar custom actions "meld left" and "meld right" which call "your_util_path/set_left.sh %F" and "your_util_path/compare_to_left.sh %F", respectively. Then,

  2. set_left.sh contains:

    echo $1 > your_util_path/MELD_LEFT_FILE

and

  1. compare_to_left.sh contains:

    echo $1 > your_util_path/MELD_RIGHT_FILE

    meld $(head -n1 your_util_path/MELD_LEFT_FILE) $1

I use this because often the two paths you want to compare are in different tabs or windows.

Jose
  • 21
1

I've been looking for a way to do this since leaving DiffMerge in Windows. I got it working in Fedora 29 with help from other answers, including @Jose's. The method should be very similar for Ubuntu. This method is useful if you need to compare files/folders from arbitrary locations.

Add the following two scripts to ~/.local/share/nautilus/scripts:

Note that the names are literally 'Compare Left' and 'Compare Right' so they appear naturally in the context menu.

Compare Left

#!/bin/bash

if [ -z "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]
then
      echo -e "$NAUTILUS_SCRIPT_CURRENT_URI" > /tmp/MELD_LEFT_FILE
else
      echo -e "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" > /tmp/MELD_LEFT_FILE
fi

Compare Right

#!/bin/bash

if [ -z "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]
then
      echo -e "$NAUTILUS_SCRIPT_CURRENT_URI" > /tmp/MELD_RIGHT_FILE
else
      echo -e "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" > /tmp/MELD_RIGHT_FILE
fi

meld $(head -n1 /tmp/MELD_LEFT_FILE) $(head -n1 /tmp/MELD_RIGHT_FILE)

Don't forget to make both scripts executable:

chmod +x 'Compare Left' 'Compare Right'

To add key bindings for the above add the following to ~/.config/nautilus/scripts-accels (be careful not to add empty lines or add lines with whitespace):

F3 Compare Left
F4 Compare Right

You will need to restart nautilus for the key bindings to work (nautilus -q)

Chris
  • 11
1

There is a nautilus-compare plugin, available in Ubuntu 16.04, 18.04, but not in 20.04. https://packages.ubuntu.com/search?keywords=nautilus-compare

sudo apt install nautilus-compare

It provides three options in Nautilus context menu:

  • "Compare"
  • "Compare to ~/foo/bar"
  • "Compare Later"

In action: enter image description here

GUI to select a diff tool:

Nautilus Compare Extension GUI

Homepage: https://launchpad.net/nautilus-compare

matthieu
  • 123
graceman9
  • 111
0

Another solution for Nemo that can compare not only files but also folders:

Copy these lines to a file named something like open_with_meld.nemo_action located in /.local/share/nemo/actions.

 [Nemo Action]

Name=Compare with meld Comment=Open two files or folders with meld and compare Exec=meld %F Icon-Name=meld Selection=any Extensions=any;

If you want to go further and also want to be able to use save for later and compare with saved Nemo actions you can use the two action scripts and complementary shell script suggested in the Archlinux Wiki: https://wiki.archlinux.org/title/Nemo#Meld_compare