10

I want to always see the total lines and % part ( line 1/773 0% ) in the bottom status / prompt for man pages immediately upon viewing one.

When I open any man page I see this in the bottom line:

 Manual page man(1) line 1 (press h for help or q to quit)

But after pressing End then Home it changes to this:

 Manual page man(1) line 1/773 0% (press h for help or q to quit)

How can I always see the total lines and % when initially opening a man page, without pressing buttons?


I'm using less as man's pager, and it's beginning to look like less "just won't do that." I'd rather not install any extra programs (default Ubuntu/Xubuntu) or change man's pager, but if another pager that's similar to less works that'd be ok (most has nice colours, but it would need it's default Prompt changed).

I thought it'd be a simple setting, but maybe not. I've tried a web search and searching this site, but didn't find anything relevant, maybe the % isn't very search-friendly or my keywords are off? Nothing in man man seemed relevant either, and the only %'s were unrelated.

1
  • 1
    Maybe it has to do with "Less does not have to read the entire input file before starting, so with large input files it starts up faster than text editors like vi (1)." from man less.
    – DK Bose
    Apr 16, 2017 at 1:56

1 Answer 1

9

Presumably, you are using less as the pager. You can not do what you want directly without recompiling less (at least i am not finding any such option) -- to read all the lines at first, get the end line number, and jump to the top with that info. But i think that would be clumsy and inefficient given the only prize is the total line number although YMMV.

Now, i am going to show you a hacky way, leveraging the LESS environment variable that less reads to get automatic option(s):

 LESS='+Gg' man <whatever>

For example:

LESS='+Gg' man bash

Inside less, G will go to end (without any line number), and g will jump to the top (without any line number). As there will done by less at first, it will have the idea of the total line numbers while coming back on top, and will show you that. Again this has the caveat of reading till the end once, and then coming back on top.

3
  • +1 I almost always press End & Home when looking at a new man page anyway, so this would be pretty good, especially in an alias for man
    – Xen2050
    Apr 16, 2017 at 4:49
  • 1
    Works good as alias man='LESS=+Gg man' Thanks
    – Xen2050
    Dec 24, 2017 at 21:39
  • is this LESS='+Gg' man bash supposed to show the line numbers? Because it doesn't do that for me.
    – ZenVentzi
    Sep 10 at 4:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.