gitpager

Turning off the pager in Git by default


Turning off the pager in Git for the stash command only and Disable all paging in Git doesn't answer this question, because I sometimes want use the pager, but not by default. I just want Git to use a pager when I add the -p option.

One partial solution, I think, that can do in some pieces, for example, for the branch command:

git config --global pager.branch false

For me, it is the best solution, but -p will not work:

git config --global core.pager ""

As I use a terminal with a scroll bar, it seems for me that it will be more productive to limit the entries of output than to put in a pager. For me, instead of write in the terminal (I use Konsole), for here I can copy, paste and search. If the output goes to a pager, the output will be lost forever when we leave the pager.

Now I just need to find out, how I limit the results to 100 or 200.

I mean, git log by default be git log -100.

In conclusion, Git doesn't offer an option to do this, so this question falls in Disable all paging in Git.


Solution

  • Git doesn't offer an option to do this, so you have a couple of options:

    git () {
        local pager=""
        
        for arg in "$@"
        do
            [ "$arg" = "-p" ] && pager="-c core.pager=less"
        done
    
        command git $pager "$@"
    }