Skip to content

Instantly share code, notes, and snippets.

@comaldave
Created December 1, 2020 21:46
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 comaldave/67217aa4791e102562f40c0b9a89c915 to your computer and use it in GitHub Desktop.
Save comaldave/67217aa4791e102562f40c0b9a89c915 to your computer and use it in GitHub Desktop.
Enable git-style colour output in regular diff on Mac OS X

Enable git-style colour output in regular diff

Mac OS X

  1. Install colordiff using Homebrew:

     brew install colordiff
    
  2. Add function to your ~/.bash_profile:

     cat <<EOF >>~/.bash_profile
    
     function diff {
         colordiff -u "$@" 
     }
     EOF
    
  3. Change default output colours to match git:

     cat <<EOF >~/.colordiffrc
     newtext=green
     oldtext=red
     diffstuff=cyan
     EOF
    
  4. Reload:

     . ~/.bash_profile
    
  5. Profit.


Notes on switches:

  • -u in diff means: unified diff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment