Right-click any file, folder, or the background of a Nemo window inside a git repository to open a diff in Meld.
- Right-click a file - diff that file
- Right-click a folder icon - diff the contents of that folder
- Right-click the empty area of a Nemo window - diff the contents of the current directory
If the file or directory has no changes, a popup tells you so. If the path is not inside a git repository, an error popup is shown. Both popups appear in front of the Nemo window.
- Meld
xdotool(used to bring the popup in front of Nemo)zenity(usually installed by default on GNOME/Cinnamon)git
On Debian/Ubuntu/Mint:
sudo apt install meld xdotool zenity1. Create the actions directory if it doesn't exist:
mkdir -p ~/.local/share/nemo/actions2. Copy the script and make it executable:
cp git-meld-diff.sh ~/.local/share/nemo/actions/
chmod +x ~/.local/share/nemo/actions/git-meld-diff.sh3. Copy the three action files:
cp git-meld-diff-file.nemo_action ~/.local/share/nemo/actions/
cp git-meld-diff-dir.nemo_action ~/.local/share/nemo/actions/
cp git-meld-diff-bg.nemo_action ~/.local/share/nemo/actions/4. Edit the three .nemo_action files:
Replace /home/ozh/ with your own home directory path (full path, not ~/you).
5. Restart Nemo:
nemo -q ; sleep 1 ; nemo &The script shared by all three actions. Handles file, directory, and background cases.
#!/bin/bash
# Open Meld to show git diff for a file or directory
TARGET="${1#file://}"
WINDOWID=$(xdotool getactivewindow 2>/dev/null)
zenity_msg() {
local type="$1"
local msg="$2"
if [ -n "$WINDOWID" ]; then
zenity --"$type" --text="$msg" --attach="$WINDOWID" 2>/dev/null
else
zenity --"$type" --text="$msg" 2>/dev/null
fi
}
if [ -f "$TARGET" ]; then
DIR=$(dirname "$TARGET")
else
DIR="$TARGET"
fi
GIT_ROOT=$(git -C "$DIR" rev-parse --show-toplevel 2>/dev/null)
if [ -z "$GIT_ROOT" ]; then
zenity_msg "error" "Not a git repository."
exit 1
fi
if [ -f "$TARGET" ]; then
# Single file: diff that file
if git -C "$GIT_ROOT" diff --quiet -- "$TARGET" && \
git -C "$GIT_ROOT" diff --quiet --cached -- "$TARGET"; then
zenity_msg "info" "No changes in this file."
exit 0
fi
meld "$TARGET" &
else
# Directory: diff scoped to that directory
if git -C "$GIT_ROOT" diff --quiet -- "$DIR" && \
git -C "$GIT_ROOT" diff --quiet --cached -- "$DIR"; then
zenity_msg "info" "No changes in this directory."
exit 0
fi
meld "$DIR" &
fiAppears when right-clicking a file.
[Nemo Action]
Name=Git diff with Meld
Comment=Show uncommitted changes in Meld
Exec=/home/ozh/.local/share/nemo/actions/git-meld-diff.sh %F
Icon-Name=meld
Selection=S
Mimetypes=text/plain;text/html;text/css;text/xml;text/x-script.python;text/x-php;text/x-shellscript;text/x-markdown;application/javascript;application/json;application/xml;application/x-php;application/x-shellscript;Appears when right-clicking a folder icon.
[Nemo Action]
Name=Git diff with Meld
Comment=Show uncommitted changes in Meld
Exec=/home/ozh/.local/share/nemo/actions/git-meld-diff.sh %F
Icon-Name=meld
Selection=S
Mimetypes=inode/directory;Appears when right-clicking the empty background of a Nemo window.
[Nemo Action]
Name=Git diff with Meld
Comment=Show uncommitted changes in Meld
Exec=/home/ozh/.local/share/nemo/actions/git-meld-diff.sh %P
Icon-Name=meld
Selection=None
Extensions=any;- The
Mimetypeslist in the file action covers common dev file types. If a file type you use is missing from the right-click menu, check its mimetype withfile --mime-type yourfileand add it togit-meld-diff-file.nemo_action. - For directory and background actions, Meld is scoped to the target directory, not the git root, so you only see changes relevant to where you clicked.
xdotoolcaptures the active window ID at script start so the popup attaches to Nemo even after focus changes.