Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Word wrap when using git grep

I am trying to run git grep from terminal (using Titanium). The results do not wrap and get cut off at the window so I cannot read anything. I tried messing around with config but could not get anything. How can I make these grep results wrap?

like image 220
Zac Avatar asked Oct 21 '11 17:10

Zac


People also ask

What does git grep do?

Git Grep. Git ships with a command called grep that allows you to easily search through any committed tree, the working directory, or even the index for a string or regular expression. For the examples that follow, we'll search through the source code for Git itself.

Which statement is the best comparison between git grep and grep?

The git grep version will only search in files tracked by git, whereas the grep version will search everything in the directory. So far so similar; either one could be better depending on what you want to achieve.


1 Answers

Have you set core.pager in your .gitconfig? If you are using less, you can see the extra characters by pressing the right arrow key on the keyboard.

Edit: Even when I unset core.pager, git grep seems to invoke less -S by default.

Edit 2: Whoops, as Keith Thompson pointed out less does wrap lines by default. From the man page:

   -S or --chop-long-lines
          Causes lines longer than the screen width to be  chopped  rather
          than  folded.  That is, the portion of a long line that does not
          fit in the screen width is not shown.  The default  is  to  fold
          long lines; that is, display the remainder on the next line.
like image 127
Oscar Korz Avatar answered Sep 30 '22 14:09

Oscar Korz