I wanted to change the default behavior of the less
command, so I added the following to ~/.profile
:
LESS="$LESS -x4"
export LESS
However, the mere presence of a set LESS
environment variable seems to change the behavior of the less
command, since this now causes git diff
to show me raw escape sequences.
More generally, the output of
LESS='' git diff
and
unset LESS; git diff
differs. What is the difference between having LESS
unset and LESS
set to an empty value (besides the former apparently implying -R
)?
This has nothing to do with
less
, and everything to do withgit
. Quoting from thegit-config(1)
manpage (emphasis mine):The
R
option ofless
is that which controls whether it interprets colors escapes and such, and which is NOT on by default, but is only set bygit
if theLESS
environment variable was unset.$LESS
is an environment variable used byless
. Fromman less
:You should use some other environment variable name.