I know I can have less show me the status line with =. Is there a way to have it displayed constantly and updated as I scroll through the file? When I use man it's actually done this way but I don't know how it's configured.
2 Answers
If you want to change the prompt (as it's called), -P is probably what you want (quote from the manual):
-Pprompt or --prompt=prompt
Provides a way to tailor the three prompt styles to your own preference.-Psfollowed by a string changes the default (short) prompt to that string.-Pmchanges the medium (-m) prompt.-PMchanges the long (-M) prompt. [...] See the section on PROMPTS for more details.
There's a bunch of variables you can use presented in the section on prompts. On my system, the = prompt displays lines and bytes, so let's set the $LESS variable to show lines and bytes that are visible on the screen in the short (default) prompt:
$ LESS='-Pslines %lt-%lb (%Pt-%Pb \%) bytes %bt-%bb file %f' ; export LESS
$ less foo
displays a prompt like lines 1-44 (1-53 %) bytes 0-2498 file foo
(%l, %P, %b for lines, percentage and bytes, trailing t and b for "top" and "bottom" of screen. %, ?, :, . and \ are special and need to be escaped.)
The default prompt also has conditionals to not show fields that are unknown, and also to show (END) instead of 100% at the end of file. As an example, the latter can be done with
?e(END):%pB\%..
- 138,973
The -M option (also --LONG-PROMPT) does this.
A few variations are listed in the manual:
-mor--long-prompt
Causes less to prompt verbosely (like more), with the percent into the file. By default, less prompts with a colon.
-Mor--LONG-PROMPT
Causes less to prompt even more verbosely than more.
- 76,765
-
-Msurprisingly doesn't seem very verbose at all, just showed current lines vs. bytes from-mfor my piped data. – Pysis Mar 11 '20 at 13:59 -
Is the
-Mformat not standardized? For me,-Mgives me filename, line range, and percentage.-monly gives me percentage, nothing else. – Ken Williams Dec 18 '23 at 02:29
(END)is done with?e. You can see the default prompt by typing-Pand hitting enter. Thanks! – musiKk Jul 27 '16 at 16:25