Skip to content

Instantly share code, notes, and snippets.

@wx13
Created June 3, 2011 19:59
Show Gist options
  • Save wx13/1007056 to your computer and use it in GitHub Desktop.
Save wx13/1007056 to your computer and use it in GitHub Desktop.
bash script to colorize diff output, kind of like git does
#!/bin/bash
RED=`echo -e '\033[31m'`
GREEN=`echo -e '\033[32m'`
BLUE=`echo -e '\033[36m'`
YELLOW=`echo -e '\033[33m'`
NORMAL=`echo -e '\033[0m'`
diff -uN $@ \
| sed "s/^@@.*@@/$BLUE&$NORMAL/g" \
| sed "s/^\+[^+].*/$GREEN&$NORMAL/g" \
| sed "s/^\-[^-].*/$RED&$NORMAL/g" \
| sed "s/^\+\+\+/$GREEN&$NORMAL/g" \
| sed "s/^\-\-\-/$RED&$NORMAL/g" \
| less -R
@morimkh
Copy link

morimkh commented Oct 4, 2017

ok. very good

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