Home > database >  How to force git's pager to wrap long lines?
How to force git's pager to wrap long lines?

Time:05-25

On most machines where I use git, long lines in the output of commands like git diff and git show are wrapped.

On one machine, though, long lines are truncated, and I have to use the left and right arrow keys to scroll the screen horizontally. I don't like this behavior at all, and I need to change it.

I assume this is a configuration variable in git's pager, or something. Does anyone know what it is?

I have seen this inverse question but I haven't been able to infer an answer to my question from it.


Update: I was under the impression that git had its own built-in pager. Experimentation with ps, however, suggests that on the machine where it works properly (does wrap) there's a program /usr/bin/pager running, whereas on the machine where it's "broken" (that is, requires horizontal scrolling), the running pager is less. So perhaps this is a less question, not a git question.

CodePudding user response:

As it appears that the culprit is less AND the default of less in the source distribution is to wrap lines, this sounds like you have inherited a shell where this has been configured explicitly.

First of all you can toggle this by typing -S at the prompt.

Check for the presence of LESS environment variable, and whether it holds a value containing 'S'. If so you need to adapt it to have S.

On my Mac, this works:

export LESS= S
  • Related