How to colorize diff on the command line
Man pages for diff
suggest no solution for colorization from within itself. Please consider using colordiff
. It's a wrapper around diff
that produces the same output as diff, except that it augments the output using colored syntax highlighting to increase readability:
diff old new | colordiff
or just:
colordiff old new
Installation:
- Ubuntu/Debian:
sudo apt-get install colordiff
- OS X:
brew install colordiff
orport install colordiff
Exclude a directory from git diff
Assuming you use bash, and you've enabled extended globbing (shopt -s extglob
), you could handle that from the shell side:
git diff previous_release current_release !(spec)
Saves you having to list all other things.
Or, shell-agnostic:
git diff previous_release current_release --name-only | grep -v '^spec/' \
| xargs git diff previous_release current_release --
You could wrap that up in a one-liner shell script to save yourself having to retype the arguments.
Diff files present in two different directories
You can use the diff
command for that:
diff -bur folder1/ folder2/
This will output a recursive diff that ignore spaces, with a unified context:
- b flag means ignoring whitespace
- u flag means a unified context (3 lines before and after)
- r flag means recursive
Related Topics
Shell Script Issue with Filenames Containing Spaces
Where Is $Path Set? Specifically Where Is My MAC Port Path Being Set
How to Merge Two Seperate - Yet Similar - Codebases into One Svn Rep
Installing Gnu Parallel Without Root Permission
Why Doesn't Linux Accept() Return Eintr
Curl Command Doesn't Work in Bash Script
Delete Files with Backslash in Linux
/Var/Log/Daemon.Log Taking More Space How to Reduce It
Determine Vm Size of Process Killed by Oom-Killer
R Package Installation in Linux
Can't Find Unexpected Operator (Bash Error)
Substitution on Range of Lines