How to make less -S not take up the entire screen

lessterminal

suppose I have this: cat new_file.txt | less -FRSX

Then suppose I press the right button in order to scroll to the right

This will cause the contents of new_file.txt to move to the top of the command line and moreover there's a whole bunch of empty space between content of new_file.txt and the current command

For instance here's what it'll look like

contentsofnewfile.txtyupmorecontenntsconteeentsss
~
~
~
~
~
~
~
~
.
.
.
~
(END)

how do I make it so that even if I press the right button, the content of the file stays where it is instead of moving to the top (though it should still scroll to the right) and moreover that there will be no empty lines such as the

~
~
~

displayed above

Best Answer

Do a cat new_file.txt | less -FRSXc. That fixes the first issue.

For the second issue use a tilde cat new_file.txt | less -FRSXc~

From the man pages for less:

-c or --clear-screen Causes full screen repaints to be painted from the top line down. By default, full screen repaints are done by scrolling from the bottom of the screen.

-~ or --tilde Normally lines after end of file are displayed as a single tilde (~). This option causes lines after end of file to be displayed as blank lines.

Related Question