Search code examples
gitzshiterm2less-unix

Behavior of git and less in iTerm2 and Zsh - do not use separate view/alternate screen


Using less-like commands in Zsh with iTerm2, e.g. running git log --graph -n 3, git stash list, or less README.md, puts the output in a separate view. I would like the behavior to be more like cat where the output stays in the main window. E.g. when I am using git log, I want to be able to refer back to the commit hashes I just saw.


Solution

  • The fix is an iTerm2 setting "Disable save/restore alternate screen" found in iTerm2>Preferences>Terminal. Checking the associated box gives the desired behavior.