41

I just switched to Oh My Zsh and I'm using the Avit theme.

When I type git log --oneline my output seems to be piped to less. It does this for whatever theme I use.

When I used bash shell, it never cleared the screen to output those lines.

How do I set it up so that it doesn’t clear the screen to output lines but instead just output the lines after I type the command?

Here's a screenshot for reference:

enter image description here

2
  • 1
    Please check first the output of which git and echo $GITPAGER. And second, if git --no-pager log --oneline works as expected.
    – mpy
    Oct 5, 2014 at 17:54
  • 2
    This lead me in the right direction. I ended up running git config --global core.pager ''. If you answer this question, I will checkmark your post. :)
    – Paul
    Oct 5, 2014 at 18:20

5 Answers 5

12

You can define a pager, which git uses by default for its output via

  1. the $GIT_PAGER or $PAGER environment variable
  2. the git config entry core.pager

The pager can be temporary disabled with the git command line option --no-pager. How to make it permanent depends upon the both possibilities above:

  1. find, where in your shell's config files the $GIT_PAGER or $PAGER environment variable gets defined and remove that line.

  2. run git config --global core.pager ''

44

oh-my-zsh runs less command with -R (repaint). You can disable this behavior by adding the following line at the end of your ~/.zshrc

unset LESS;

This is set to -R in ~/.oh-my-zsh/lib/misc.zsh

Source: https://stackoverflow.com/a/49267711/1050554.

4
  • 3
    I thought this comment does not work, but it does, I missed the part of adding unset to the END of zshrc Oct 17, 2019 at 12:49
  • 7
    This should be the accepted answer IMO... it's not a git thing but oh-my-zshs Oct 15, 2020 at 8:14
  • @josemigallas Absolutely. This "feature" of oh my zsh is ridiculous. Sep 3, 2021 at 17:28
  • 1
    -R is nice to keep colors. Based on this and zqb-all's solution, setting LESS=-RFX works nice for me
    – redbmk
    Oct 17, 2021 at 22:14
24

maybe a better solution :

git config --global --replace-all core.pager "less -F -X"

from How do I prevent git diff from using a pager?

1
  • 2
    This is really better. I'll explain why: with "plain" less, when you do, for instance, git log – all your history disappears after you quit the pager. With this command, it stays on screen. If the log is really short (fits the screen) — it doesn't use the pager at all. Only if content is long enough, it would be wrapped in pager, and you'll not lose the screen after clicking "q".
    – pilat
    May 23, 2018 at 10:56
4

A simple way to fix this is to make git log not use the pager in the global configuration settings:

git config --global pager.log false

2

Edit file ~/.zshrc and add

PAGER=

Then, save the file and execute source ~/.zshrc.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .