Turn off line wrapping when running git grep

559 Views Asked by At

Sometimes I do a git grep, and there's that one line which is so long it takes up half a page or more because of line wrapping. How can I tell git grep to turn of line wrapping, instead requiring me to scroll to the right if I want to see the rest of a long line?

I'm using Terminal on OSX, if that's relevant. https://git-scm.com/docs/git-grep didn't indicate which program the git grep command outputs to, if any.

1

There are 1 best solutions below

0
On BEST ANSWER

git grep filters its output through the program set in the environment variable GIT_PAGER, so you just need to set that variable to an appropriate pager. Or, set your environment so that the pager it uses exhibits the behavior you want. For example, either GIT_PAGER="less -S" or LESS=-S should work (assuming your default PAGER is less). You need to put those in the environment, so you might either put export GIT_PAGER or export LESS in your shell startup scripts, or run GIT_PAGER="less -S" git grep ...