Is there a way to configure git to pipe its output into a paper only when it exceeds the terminal size (or at least a specific number of lines)? I think it's rather annoying that e.g. a 6-line diff is shown in the pager - hiding any previous output, and requiring me to explicitly press "q" to exit.
On most systems, less
is the default pager that Git uses and you can configure less to behave like you describe with:
git config --global core.pager "less -X -F"
-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.
See this answer for more options with configuring less.
Also, specifically with regards to the diff
command you can use:
git --no-pager diff
You can configure your pager by setting the PAGER
variable, and any program which needs a pager will use it. less
has an option -F
which does exactly this. Adding export PAGER="less -F"
to your ~/.bashrc
will make this permanent.
Personally I use less -FXRS
; see the man page for less for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With