From 8ed1655d10a2af4aea9855c7090c677c99015c41 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Tue, 9 Feb 2021 18:35:11 -0600 Subject: [PATCH] Add Set A Custom Pager For A Specific Command as a git til --- README.md | 3 +- ...t-a-custom-pager-for-a-specific-command.md | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 git/set-a-custom-pager-for-a-specific-command.md diff --git a/README.md b/README.md index b30b66a..a65483a 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/git/set-a-custom-pager-for-a-specific-command.md b/git/set-a-custom-pager-for-a-specific-command.md new file mode 100644 index 0000000..1db955c --- /dev/null +++ b/git/set-a-custom-pager-for-a-specific-command.md @@ -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.` +sections.