Is it possible to keep the output of less on the screen after quitting?

For Git specifically, this can be handled with the following

git config --global color.ui true
git config --global core.pager 'less -Xr'

To prevent less from clearing the screen on exit you can start it with the option -X:

less -X FILE

If you want to pass this option automatically to every instance of less, you can set the LESS environment variable accordingly in your ~/.zshrc:

export LESS="-X"

Note: If your shell has syntax coloring enabled, the -X option will cause your less output to display those color change escape sequences as inline ESC text.
This can be fixed by also passing the raw-control-chars display option, -r. For example:

export LESS="-Xr"

This also includes instances where less is started by another program, for example man. If you want to disable this option for a single command, you can just prepend LESS=. For example

LESS= man less

Tags:

Unix

Oh My Zsh