# Useful diff Aliases

Add the following aliases to your ‘~/.bashrc’ for some diff goodness:

alias diff-side-by-side='diff --side-by-side -W"tput cols"'
alias diff-side-by-side-changes='diff --side-by-side --suppress-common-lines -W"tput cols"'

You can, of course, use shorter alias names in good old UNIX tradition, e.g. ‘ssdiff’ and ‘sscdiff’. You might be wondering why (a) I did not do so, and (b) what is the point, conversely, of having aliases that are almost as long as the commands that they are aliasing. The answer to the first is ‘memory’, and the second is ‘autocomplete’.

Shorter aliases resulted in me constantly forgetting what they were mapped to (I rarely work outside a Git repository, and thus rarely use external diff, relying/needing Git’s diff 99% of the time), and it was easier for me to Google the options than to open up my huge ‘~/.bashrc’ to look up my personal alias. And the being forced not only to look up the options but then type out all those awkward characters again and again meant that I rarely ended up using these neat diff options. However, now, with these aliases, I just type ‘diff’ and then hit ‘TAB’, and let autocompletion show me and finish off the rest the commands for me.

Share