From 945b48fbcb970659ed38f20c58fe204e91a94146 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Thu, 4 Feb 2021 11:56:19 -0600 Subject: [PATCH] Add Skip Paging If Output Fits On Screen With Less as a unix til --- README.md | 3 ++- ...ging-if-output-fits-on-screen-with-less.md | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 unix/skip-paging-if-output-fits-on-screen-with-less.md diff --git a/README.md b/README.md index 34e155e..fc6bb0e 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). -_1034 TILs and counting..._ +_1035 TILs and counting..._ --- @@ -1011,6 +1011,7 @@ _1034 TILs and counting..._ - [Show A File Preview When Searching With FZF](unix/show-a-file-preview-when-searching-with-fzf.md) - [Show Disk Usage For The Current Directory](unix/show-disk-usage-for-the-current-directory.md) - [Show The Size Of Everything In A Directory](unix/show-the-size-of-everything-in-a-directory.md) +- [Skip Paging If Output Fits On Screen With Less](unix/skip-paging-if-output-fits-on-screen-with-less.md) - [SSH Escape Sequences](unix/ssh-escape-sequences.md) - [SSH With Port Forwarding](unix/ssh-with-port-forwarding.md) - [Specify The Language For A File With Bat](unix/specify-the-language-for-a-file-with-bat.md) diff --git a/unix/skip-paging-if-output-fits-on-screen-with-less.md b/unix/skip-paging-if-output-fits-on-screen-with-less.md new file mode 100644 index 0000000..bd74674 --- /dev/null +++ b/unix/skip-paging-if-output-fits-on-screen-with-less.md @@ -0,0 +1,27 @@ +# Skip Paging If Output Fits On Screen With Less + +The `less` command can be used to display a file or the output of a command. It +is sometimes referred to as a pager because it paginates text that won't fit +onto a single screen. + +```bash +$ ls | less +``` + +This will list the files for the current directory with `less`. + +By default it will even display a small amount of text output within the pager. +If you want `less` to output text that fits onto a single screen directly to +the terminal, you can pass the `-F` and `-X` flags. + +```bash +$ ls | less -FX +``` + +The `-F` flag tells `less` to exit if the output fits onto a single screen. The +`-X` tells `less` to skip screen clearing. + +This is handy if you want the output of a command to show up in your shell +history. + +See `man less` for more details.