43

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.

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
Nullptr
  • 3,103
  • 4
  • 27
  • 28
  • 2
    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. – Jameson Nov 08 '15 at 08:23
  • Thanks. `which $PAGER` gives `/usr/bin/less`.. – Nullptr Nov 08 '15 at 08:28
  • Does /bin/cat have the behavior you want? – Jameson Nov 08 '15 at 08:42
  • 3
    sounds like a `less` issue discussed here: http://stackoverflow.com/questions/6977781/xterm-keep-page-from-less-in-terminal-after-exit – max630 Nov 08 '15 at 12:43

2 Answers2

58

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
55

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.

Alex Maystrenko
  • 1,091
  • 10
  • 11