Skip to content

Instantly share code, notes, and snippets.

@ginokent
Last active March 16, 2019 01:01
Show Gist options
  • Save ginokent/71ee27bf35b51e2472c768562663db7d to your computer and use it in GitHub Desktop.
Save ginokent/71ee27bf35b51e2472c768562663db7d to your computer and use it in GitHub Desktop.
color diff
difff() {(R=$(printf '\e[31m');G=$(printf '\e[32m');B=$(printf '\e[36m');W=$(printf '\e[1m');N=$(printf '\e[0m');diff -u "$@"|sed $(uname -s|grep -q '^Darwin'&&printf -- -E||printf -- -r) "s/(^@@.+@@|@@.+@@$)/$B\1$N/g;s/(^\+.*)$/$G\1$N/g;s/(^\-.*)$/$R\1$N/g;s/^[^\+\-]*((\+{3}|-{3}) [^ ].*)/$W\1/g;")}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment