From 1fcbe3dc469c4c9bef1a42993bb771a7765c6107 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Mon, 1 Feb 2021 18:09:01 -0600 Subject: [PATCH] Add Turn Off The Output Pager For One Command as a git til --- README.md | 3 ++- ...rn-off-the-output-pager-for-one-command.md | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 git/turn-off-the-output-pager-for-one-command.md diff --git a/README.md b/README.md index abcec37..f2fe493 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). -_1032 TILs and counting..._ +_1033 TILs and counting..._ --- @@ -280,6 +280,7 @@ _1032 TILs and counting..._ - [Stashing Only Unstaged Changes](git/stashing-only-unstaged-changes.md) - [Stashing Untracked Files](git/stashing-untracked-files.md) - [Switch To A Recent Branch With FZF](git/switch-to-a-recent-branch-with-fzf.md) +- [Turn Off The Output Pager For One Command](git/turn-off-the-output-pager-for-one-command.md) - [Two Kinds Of Dotted Range Notation](git/two-kinds-of-dotted-range-notation.md) - [Unstage Changes Wih Git Restore](git/unstage-changes-with-git-restore.md) - [Untrack A Directory Of Files Without Deleting](git/untrack-a-directory-of-files-without-deleting.md) diff --git a/git/turn-off-the-output-pager-for-one-command.md b/git/turn-off-the-output-pager-for-one-command.md new file mode 100644 index 0000000..71b2aaf --- /dev/null +++ b/git/turn-off-the-output-pager-for-one-command.md @@ -0,0 +1,25 @@ +# Turn Off The Output Pager For One Command + +With `git` a pager, such as `less`, can be configured to display paginated +command output. There are many ways to set up the default pager such as setting +the `core.pager` value in your git-config or by setting the `$PAGER` env var. + +Assuming it is set to something like `less`, you can view, scroll through, and +search the output of a command like `git log` or `git diff`. When you're +finished the pager will close, all the output will vanish, and you'll be back +at your terminal prompt. + +This is generally a desirable workflow. If, however, you want to be able to +scroll back in your terminal history to reference a SHA or a commit message, +you'll be disappointed. + +For one off commands where you know you'll want the output actually printed to +the terminal, you can turn off the pager with the `--no-pager` flag (or `-P` as +a shorthand). + +```bash +$ git --no-pager show +``` + +This will print the details of the HEAD commit to the terminal. I can scroll +back and reference them as needed.