At first it felt annoying, but now I really like that git uses a pager when it has to present something (e.g. a log or a diff) that is longer than your screen. Git even provides a built in option
--color to show you a diff with helpful colors. I use this option all the time and made a shortcut
dic for it with the following command
git config --global alias.dic "diff --color"
Also possible is to edit your
~/.gitconfig directly so you have something like the following in there:
[alias] di = diff dic = diff --color
Now I just do
and I get a nice paged and color highlighted diff.
This is a so I-wonder-how-I-could-live-without-it thingy that I wanted the same when working with Subversion or CVS. These guys don't have color highlighting built in, but luckily there is this standalone "diff colorizer" colordiff to help us out. Colordiff should be available at a sufficiently recent Linux package manager near you (Ubuntu has it since 6.06 for example), otherwise installing it manually is not that hard (it's mainly one perl script and some config files).
If we also add a pager like "less" to the mix, we can mimic the behavior of git. To do so, I added two little scripts to my
The first one is
#!/bin/sh cvs diff -bup "$@" | colordiff | less -R
and the one for Subversion is
#!/bin/sh svn diff --diff-cmd colordiff -x "-u -w -p" "$@" | less -R
I first tried with constructing bash aliases, but then things go wrong when you try to use arguments to only see diffs of certain files for example. The scripts above take care of this with the
"$@" magic, so I can do things like
svncolordiff.sh foo.cpp bar.py
Also note (in case your wondering) the
-R option for
less. This options makes sure
less presents nice colors instead of spitting color control character garbage at you.