14

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 2

11

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. -Ps followed by a string changes the default (short) prompt to that string. -Pm changes the medium (-m) prompt. -PM changes 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\%..

1
  • (END) is done with ?e. You can see the default prompt by typing -P and hitting enter. Thanks!
    – musiKk
    Jul 27, 2016 at 16:25
10

The -M option (also --LONG-PROMPT) does this.

A few variations are listed in the manual:

-m or --long-prompt
Causes less to prompt verbosely (like more), with the percent into the file. By default, less prompts with a colon.

-M or --LONG-PROMPT
Causes less to prompt even more verbosely than more.

1
  • -M surprisingly doesn't seem very verbose at all, just showed current lines vs. bytes from -m for my piped data.
    – Pysis
    Mar 11, 2020 at 13:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .