One thing I don’t like about
Combining all these together, I have added this to my
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:gituses the default pager the user has configured. On Ubuntu machines it’slesswhen$PAGERis not defined.- You can configure less by defining
$LESSvariable with the flags you want to pass by default. - Nigel McNie has posted a set of flags that are a good default flags for
less. -Xoption tolesstells it to not clear the screen when it exits. From a related question on Super User I found that passing the flag-+Xwould forcelessto always clear the screen when it exits.
~/.zshrc, and everything is just the way I want.export LESS="-+X -FR"
While adding this line made git work fine, it resulted in less behaving erratically. Now I have the following config in my ~/.gitconfig, and things seem to be good.[core]
pager = less -+X -+F