Skip to content

Instantly share code, notes, and snippets.

Created Jan 20, 2017
What would you like to do?
diffi - Better diff output script
# diffi - Better diff output script
# BeanBagKing -
# If both arguments aren't given, print help text
if [ -z $1 ] || [ -z $2 ]; then
echo "Usage: `basename $0` [OLD] [NEW]"
exit 1
# Gather Arguments
# Define variable to printf esc sequence, so it works on macOS/other non-GNU sed
esc=$(printf '\033')
# Put everything together
diff -u $OLD $NEW | sed -n '1,2d;/^[-+]/p' | sed -e "s/^-/${esc}[31m-${esc}[0m/" | sed -e "s/^+/${esc}[32m+${esc}[0m/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment