Saturday, February 25, 2012

Making git commands clear screen when they exit

One thing I don’t like about git is that commands like git diff don’t clear screen when they exit. If I view a file using less, e.g. by running less ~/.zshrc, less would clear the file content from the screen when it exits. But git diff, git log, etc. don’t. With some Googling around, I found that:

git uses the default pager the user has configured. On Ubuntu machines it’s less when $PAGER is not defined.

You can configure less by defining $LESS variable with the flags you want to pass by default.