Skip to content

Instantly share code, notes, and snippets.

@nolanatearthsense
Created December 27, 2022 17:13
Show Gist options
  • Save nolanatearthsense/65b8733b088efdad2df92a81a27467cb to your computer and use it in GitHub Desktop.
Save nolanatearthsense/65b8733b088efdad2df92a81a27467cb to your computer and use it in GitHub Desktop.
run meld in docker
#!/bin/bash
#sudo apt-get install realpath # may already be installed
PATH1=$(realpath $1)
PATH2=$(realpath $2)
[ -d $PATH1 ] || PATH1=$(dirname $PATH1)
[ -d $PATH2 ] || PATH2=$(dirname $PATH2)
echo $PATH1
echo $PATH2
XAUTH=/tmp/.docker.xauth
echo "Preparing Xauthority data..."
xauth_list=$(xauth nlist :0 | tail -n 1 | sed -e 's/^..../ffff/')
if [ ! -f $XAUTH ]; then
if [ ! -z "$xauth_list" ]; then
echo $xauth_list | xauth -f $XAUTH nmerge -
else
touch $XAUTH
fi
chmod a+r $XAUTH
fi
docker run \
-w $PWD \
--env="DISPLAY=$DISPLAY" \
--env="QT_X11_NO_MITSHM=1" \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
--env="XAUTHORITY=$XAUTH" \
--volume="$XAUTH:$XAUTH" \
-v $PATH1:$PATH1 -v $PATH2:$PATH2 \
guywithnose/meld meld $1 $2
@nolanatearthsense
Copy link
Author

nolanatearthsense commented Dec 27, 2022

Requires docker.

Copy to /usr/bin/

Example: meld file1 file2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment