1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-04 23:58:01 +00:00

Add Set A Custom Pager For A Specific Command as a git til

This commit is contained in:
jbranchaud
2021-02-09 18:35:11 -06:00
parent e5b8b9e6d7
commit 8ed1655d10
2 changed files with 33 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
_1040 TILs and counting..._
_1041 TILs and counting..._
---
@@ -264,6 +264,7 @@ _1040 TILs and counting..._
- [Renaming A Branch](git/renaming-a-branch.md)
- [Resetting A Reset](git/resetting-a-reset.md)
- [Resolve A Merge Conflict From Stash Pop](git/resolve-a-merge-conflict-from-stash-pop.md)
- [Set A Custom Pager For A Specific Command](git/set-a-custom-pager-for-a-specific-command.md)
- [Show All Commits For A File Beyond Renaming](git/show-all-commits-for-a-file-beyond-renaming.md)
- [Show Changes For Files That Match A Pattern](git/show-changes-for-files-that-match-a-pattern.md)
- [Show Changes In The Compose Commit Message View](git/show-changes-in-the-compose-commit-message-view.md)

View File

@@ -0,0 +1,31 @@
# Set A Custom Pager For A Specific Command
The pager can be [configured globally](configuring-the-pager.md), for [one run
of a command](turn-off-the-output-pager-for-one-command.md), or as I'll explain
in this post, for a specific command.
_I explore all of this in [Optimize the way Git displays the output of
commands](https://www.youtube.com/watch?v=VpFldePcu_w)._
Let's assume a git configuration that uses `less` for any command that need a
pager. Perhaps you'd like for the `git show` to work a bit differently than
other commands. You want it to use `less` with the `-F` and `-X` flags.
A custom pager command can be set for any command in the `[pager]` section of
the `~/.gitconfig` file.
```
[pager]
show = "less -FX"
```
If you want to turn off the pager for a specific command, set it to the boolean
value `false` instead.
```
[pager]
show = false
```
See `man git-config` for more details in the `core.pager` and `pager.<cmd>`
sections.