Reputation: 617
When I run git diff
on some file, what pager is it using? I ask because for every other command line tool I use with a pager in Linux, when I quit (by typing 'q'), the terminal reverts to what it was displaying before, with the only evidence that I ran s.t. being the command line itself. For example:
> git help diff
>
Same with man
, less
itself, etc. But when I run git diff
, the entire diff remains on the screen, even if it was hundreds of lines long. So if I want to look at the output of previous commands, I have to scroll way back.
This seems to be the behavior of less -X
, which "Disables sending the termcap initialization and deinitialization strings to the terminal".
I've read the documentation for git diff
, but nowhere do I see it say how to restore the terminal to the way it was before I ran the diff. I can export PAGER=/bin/less
, but this has no effect (it's maybe the default pager for git diff
).
It may be that git diff
is somehow passing a -X
parameter to less
. But if so, I don't see anyway to turn that behavior off (the man page for less
is silent about this).
Related: https://unix.stackexchange.com/questions/167735/can-less-f-be-usefully-combined-with-termcap-initialization. But that doesn't tell my why git diff
behaves as if it is passing the -X
parameter. (FWIW, my terminal reports that it's xterm-256color.)
Upvotes: 1
Views: 511
Reputation: 76499
To see which pager Git is using, you can use git var GIT_PAGER
. To find out the order of options that Git consults, you can use run git var --help
; the manual page lists the order of options.
Note that by default Git sets some options when invoking the pager by setting some environment variables. The default compile-time behavior is to set LESS=FRX
and LV=-c
. If you don't want these options, you can override them by setting the environment variable yourself, in which case your settings will override Git's defaults.
Upvotes: 2