...is it possible to configure git so that it always pipes output to less...
Yes. By default, git
uses less
as its pager, with the options FRSX
[Apologies on the non-authoritarian source].
To get the behaviour you're after, you want to disable the F
and X
options. You can do this globally:
git config --global --replace-all core.pager 'less -+X -+F'
Read this answer for a longer explanation, and man less
:
-F or --quit-if-one-screen
Causes less to automatically exit if the entire file can be displayed on the first screen.
-X or --no-init
Disables sending the termcap initialization and deinitialization strings to the terminal. This is sometimes desirable if the deinitialization string does something unnecessary, like clearing the screen.
(I'm not sure why we want -X
in this case, but apparently git
uses it by default, and turning it off exhibits the behaviour you're after.)