How to make git grep show at the top and not at the bottom of the terminal screen?

Suppose my terminal screen is 40 lines tall.

Suppose I type "clear",

Suppose the output if git grep is only 1 line.

Now the desired result that I want is for the first 10 lines of my console to be git grep outputs.

Instead, git grep fills a bunch of blank lines and prints my bottom ten lines of screen to git grep output.

How can i fix this?

+4
source share
4 answers

Are you looking for a way to prevent git grep from showing its output through a pager? Try:

 GIT_PAGER='' git grep ... 

git grep sends its result via a pager, which you can disable by setting the GIT_PAGER environment GIT_PAGER . I think you see that your pager displays text at the bottom of the screen, and not git does this. If this is not what you want, we need to learn more about what is happening.

+6
source

Even if the question is a little old, for further reference, I think the .gitconfig parameter should be mentioned here:

 # ~/.gitconfig or .git/config [pager] grep = false 

This ensures that you never use a pager when using git grep , without the need to add an extra env variable.

+4
source

You can output the output via grep as follows:

 <git command> | grep -v '^$' 
+1
source

Setting the GIT_PAGER environment variable to '' will exit all git commands without a pager.

If you want it not to be unloaded only for a specific command, for example git grep, use it with git --no--pager

+1
source

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


All Articles