Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

grep

Suppose my terminal screen is 40 lines high.

Suppose I type in "clear";

Suppose the output if git grep is only 1- lines.

Now, the desired output I want is to have the first 10 lines of my console be the output of git grep.

Instead, git grep fills in a bunch of blank lines and makes my output the bottom ten lines of the screen the output of git grep.

How can I fix this?

like image 921
anon Avatar asked Dec 17 '22 02:12

anon


2 Answers

Are you looking for a way to have git grep not show its output through a pager? Try:

GIT_PAGER='' git grep ...

git grep sends its output through a pager, which you can disable by setting the GIT_PAGER environment variable. I think what you are seeing is your pager displaying the text at the bottom of the screen, rather than git doing so. If this is not what you want, we need to know more about what's happening.

like image 99
Alok Singhal Avatar answered May 21 '23 11:05

Alok Singhal


Even if the question is a bit old, for further reference, I think the .gitconfig setting should be mentionned, here :

# ~/.gitconfig or .git/config

[pager]
  grep = false

This will ensure you never use pager when using git grep, without the need to add extra env variable.

like image 31
kik Avatar answered May 21 '23 10:05

kik