15

I realize that you can do git --no-pager <command> to prevent the output from being run through a pager. I also realize you can use, for instance, git config --global core.pager cat.

However there are some commands where I do want to use the pager automatically, e.g. diff, and others where I do not, e.g. stash. Typing out --no-pager each time is not as efficient as I'd like.

Is there any way to set configuration like this for individual commands? As an alternative, is it possible to have zsh automatically insert --no-pager when calling stash without using an alias?

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Explosion Pills
  • 188,624
  • 52
  • 326
  • 405
  • Related, but not duplicate since it concerns `stash` only, and not all commands in general: [Turning off the pager in git for the stash command only](http://stackoverflow.com/questions/4225350/turning-off-the-pager-in-git-for-the-stash-command-only). –  Aug 08 '13 at 15:28

2 Answers2

20

As this answer points out, you can use pager.stash false to turn off pagination for stash:

git config --global pager.stash false

More generally, you can use pager.<command> with other commands, like diff

git config --global pager.<command> false
git config --global pager.diff false

From the official Linux Kernel Git documentation for git config:

pager.<cmd>

If the value is boolean, turns on or off pagination of the output of a particular git subcommand when writing to a tty. Otherwise, turns on pagination for the subcommand using the pager specified by the value of pager.<cmd>. If --paginate or --no-pager is specified on the command line, it takes precedence over this option. To disable pagination for all commands, set core.pager or GIT_PAGER to cat.

Community
  • 1
  • 1
0

You can use Git aliases:

git config --global alias.nop-stash "stash --no-pager"
Hauleth
  • 22,873
  • 4
  • 61
  • 112
  • This doesn't seem to work. `stash --no-pager` generates an error, and `--no-pager stash` complains that the alias changes environment variables (which is actually what I *want* to do ... hmm – Explosion Pills Aug 08 '13 at 13:06
  • 2
    To see why this creates an error, see [Turning off the pager in git for the stash command only](http://stackoverflow.com/questions/4225350/turning-off-the-pager-in-git-for-the-stash-command-only/4226181#4226181). –  Aug 08 '13 at 15:00