git log/show etc. replaces the terminal screen
Asked Answered
U

2

46

I recently started to use zsh (oh-my-zsh, without customizations) on iTerm2. But, I'm having a trouble in git log or git show.

Previously, for example, the git log results were just a part of the terminal, just like ls -l result. After quitting git log by pressing q key, the result was remained in the terminal screen. I was able to pick some hash id easily.

However, the current problem is that git log (or git show) results replace the screen. So, after quitting git log, the terminal completely removes all git results and returns to the original screen. This behavior is like vim.

This behavior is the same even with bash or Mac's default terminal app. This is not a problem of --no-pager.

Any helps would be appreciated.

Unalienable answered 8/11, 2015 at 8:18 Comment(4)
Do you have PAGER set to anything? PAGER=/bin/cat or PAGER=/usr/bin/less seem like sane options. Default in my environment is to operator like /usr/bin/less, when the value is not set.Twinflower
Thanks. which $PAGER gives /usr/bin/less..Unalienable
Does /bin/cat have the behavior you want?Twinflower
sounds like a less issue discussed here: #6978281Allenaallenby
C
60

Can you try with:

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

From "How do I prevent git diff from using a pager?":

passing the -F option to less causes it to quit if the content is less than one screen, however after doing so the screen is reset and you end up not seeing the content, the -X option does away with that behaviour.

Cioban answered 8/11, 2015 at 8:57 Comment(1)
Thank you so much. It fixes the problem! Wow, so many hidden options and weird behaviors.Unalienable
A
61

oh-my-zsh executes less with -R flag, You may run unset LESS to fallback to default behaviour.

If you want to make this change persistent, put this command to .zshrc.

Acriflavine answered 13/3, 2018 at 23:52 Comment(6)
Thanks, it works. I also think it's change from oh-my-szh because git log still working fine in normal bash shellCalifate
You may dig into .zshrc and other zsh settings to set correct flags for less.Acriflavine
I think this is the better answer, as it mitigates the root cause. Changing git config did not help me with e.g. aws aliases.Memoir
I much prefer this method. Just finally upgraded to Catalina and this whole 'new page' thing was bugging me! :DMedieval
combining these two answers, you can also set LESS=-RFXTiresias
My saviour! I have almost set down to Tony Buzan's "Use Your Memory" again to help me memorize those SHA1s. Now I can again just copy them 🙏🏻Otto
C
60

Can you try with:

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

From "How do I prevent git diff from using a pager?":

passing the -F option to less causes it to quit if the content is less than one screen, however after doing so the screen is reset and you end up not seeing the content, the -X option does away with that behaviour.

Cioban answered 8/11, 2015 at 8:57 Comment(1)
Thank you so much. It fixes the problem! Wow, so many hidden options and weird behaviors.Unalienable

© 2022 - 2024 — McMap. All rights reserved.