Skip to content

Instantly share code, notes, and snippets.

@kdart
Last active September 22, 2018 23:04
Show Gist options
  • Save kdart/293b74f8b55b3aca589a5bb06209a852 to your computer and use it in GitHub Desktop.
Save kdart/293b74f8b55b3aca589a5bb06209a852 to your computer and use it in GitHub Desktop.
Use [g]vimdiff as the diff tool in git.
#!/bin/sh
# shell wrapper to use gvimdiff and vimdiff as git differ.
# set up your ~/.gitconfig like this to use it:
#[diff]
# external = gitdiff.sh
#
#[pager]
# diff =
# ndiff = less
#
#[alias]
# ndiff = diff --no-ext-diff
# The ndiff alias is the "normal diff" in case you don't want to use vimdiff some times.
# This will use gvimdiff in a graphical environment (DISPLAY is set), or run an
# in-terminal vimdiff if not.
# Also, put this in your ~/.vimn/vimrc file to make exiting quicker.
#
# if &diff
# nmap ZZ :qall<CR>
# endif
if [ -n "$DISPLAY" ] ; then
DIFF="/usr/local/bin/gvimdiff -RMmf"
else
DIFF="/usr/local/bin/vimdiff -RMm"
fi
LEFT=${2}
RIGHT=${5}
exec $DIFF "$LEFT" "$RIGHT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment