Constantly display status line in less

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.


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\%..

Tags:

Less