Skip to content

Instantly share code, notes, and snippets.

@DennisTT
Created February 4, 2013 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DennisTT/4710888 to your computer and use it in GitHub Desktop.
Save DennisTT/4710888 to your computer and use it in GitHub Desktop.
Opens up DiffMerge comparing a local version of the file (base) with a modified version on a remote machine. Assumes that the directory structure is the same after "cache directory" configuration value.
#!/bin/bash
# Opens up DiffMerge comparing a local version of the file (base) with a modified version
# on a remote machine. Assumes that the directory structure is the same after "cache
# directory" configuration value.
# Configuration values
LOCALCACHEDIR="/var/repo/cache/"
REMOTECACHEDIR="/home/remoteuser/repo/cache/"
REMOTESERVERNAME="staging"
# End configuration
FOLDERNAME=$(dirname $1)
LOCALDIR=$LOCALCACHEDIR$FOLDERNAME
REMOTEDIR=$REMOTECACHEDIR$FOLDERNAME
LOCALFILE=$LOCALCACHEDIR$1
REMOTEFILE=$REMOTECACHEDIR$1
TEMPFILE="/tmp/$(basename $0).$$.tmp"
# Update local version
(
cd $LOCALDIR
git pull
)
# Check local file exists
if [ ! -f $LOCALFILE ]; then
echo "$LOCALFILE does not exist"
exit 1
fi
# Get remote version into temp file
scp $REMOTESERVERNAME:$REMOTEFILE $TEMPFILE
# Open up diff
(
diffmerge $LOCALFILE $TEMPFILE
rm $TEMPFILE
) &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment