Skip to content

Commit 8ed1655

Browse files
committed
Add Set A Custom Pager For A Specific Command as a git til
1 parent e5b8b9e commit 8ed1655

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010

1111
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
1212

13-
_1040 TILs and counting..._
13+
_1041 TILs and counting..._
1414

1515
---
1616

@@ -264,6 +264,7 @@ _1040 TILs and counting..._
264264
- [Renaming A Branch](git/renaming-a-branch.md)
265265
- [Resetting A Reset](git/resetting-a-reset.md)
266266
- [Resolve A Merge Conflict From Stash Pop](git/resolve-a-merge-conflict-from-stash-pop.md)
267+
- [Set A Custom Pager For A Specific Command](git/set-a-custom-pager-for-a-specific-command.md)
267268
- [Show All Commits For A File Beyond Renaming](git/show-all-commits-for-a-file-beyond-renaming.md)
268269
- [Show Changes For Files That Match A Pattern](git/show-changes-for-files-that-match-a-pattern.md)
269270
- [Show Changes In The Compose Commit Message View](git/show-changes-in-the-compose-commit-message-view.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Set A Custom Pager For A Specific Command
2+
3+
The pager can be [configured globally](configuring-the-pager.md), for [one run
4+
of a command](turn-off-the-output-pager-for-one-command.md), or as I'll explain
5+
in this post, for a specific command.
6+
7+
_I explore all of this in [Optimize the way Git displays the output of
8+
commands](https://www.youtube.com/watch?v=VpFldePcu_w)._
9+
10+
Let's assume a git configuration that uses `less` for any command that need a
11+
pager. Perhaps you'd like for the `git show` to work a bit differently than
12+
other commands. You want it to use `less` with the `-F` and `-X` flags.
13+
14+
A custom pager command can be set for any command in the `[pager]` section of
15+
the `~/.gitconfig` file.
16+
17+
```
18+
[pager]
19+
show = "less -FX"
20+
```
21+
22+
If you want to turn off the pager for a specific command, set it to the boolean
23+
value `false` instead.
24+
25+
```
26+
[pager]
27+
show = false
28+
```
29+
30+
See `man git-config` for more details in the `core.pager` and `pager.<cmd>`
31+
sections.

0 commit comments

Comments
 (0)