Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I turn on a pager for the output of git status?

Tags:

git

I want the output of git status to be returned in a less-like environment. This already works for git diff, but not git status. I already tried adding the following to ~/.gitconfig, but it didn't work:

[core]   pager = less 

What am I missing? Thanks.

like image 938
Waldo000000 Avatar asked Jan 16 '12 16:01

Waldo000000


People also ask

What is git pager?

When you run Git commands that produce a bunch of output, Git will use a pager to present the content starting at the beginning, rather than spitting it all out to the screen at once. This will almost always come in handy for commands like git-diff and git-log . By default, Git uses less as its pager.

What is git no pager?

--no-pager to Git will tell it to not use a pager. Passing the option -F to less will tell it to not page if the output fits in a single screen. Usage: git --no-pager diff.


2 Answers

You can turn on and off paging of specific commands with the pager.<cmd> setting, in this case pager.status:

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>.

Run the following to enable paging for status subcommand:

git config --global pager.status true 

or manually add the following to the end of your ~/.gitconfig:

[pager]     status = true 

If you just want to turn paging on or off for a specific invocation, you can use option -p/--paginate respectively -P/--no-pager to the git command itself as well, e.g.:

git -p status 
like image 150
meagar Avatar answered Sep 20 '22 23:09

meagar


For one-off:

git -p status 

Or --paginate. Colourised. Works everywhere. Including errors/help.

git -p status -h is much better than having to grab stderr with git status -h |& less

Though long help messed up my terminal: git -p status --help

like image 30
hyperpallium Avatar answered Sep 19 '22 23:09

hyperpallium