Word wrap when using git grep

I am trying to run git grep from a terminal (using Titanium). The results are not wrapped and clipped in the window, so I can’t read anything. I tried to mess with the configuration, but could not get anything. How can I make these grep results wrapped?

+6
source share
3 answers

Have you core.pager in .gitconfig ? If you use less , you can see additional characters by pressing the right arrow key on the keyboard.

Edit: Even if I disabled core.pager , git grep defaults to less -S .

Edit 2: Oops, as Kate Thompson pointed out, less does the default wrapper. On 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. 
+6
source

Try connecting the output via cat .

+3
source

With a pager, like less, git grep already able to pass parameters to the specified pager:

 -e 

The next parameter is the template.
This option should be used for patterns starting with - and should be used in scripts that pass user input to grep.

Running git 2.0.1 (June 25, 2014), which also works with case insensitive git grep .

See commit f7febbe from Johannes Schindelin ( dscho ) :

git grep -O -i : if the pager is " less ", go to the option " -I "

When <command> turns out to be the magic string " less ", today

 git grep -O<command> -e<pattern> 

helps +/<pattern> skip less, so you can navigate through the results in the file using the n and shift + n keys.

Alas, this is not case-insensitive,
i.e.

 git grep -i -O<command> -e<pattern> 

In this case, we must go --IGNORE-CASE to " less " so that n and shift + n can move between the results, ignoring case in the pattern.

The original patch came from msysgit and was used by " -I ", but this was not due to lack of support for " -I ", but simply overlooked that it should work even if the template contains uppercase letters.

0
source

Source: https://habr.com/ru/post/899810/


All Articles