When viewing a man page, is there a way to see visually where you are in the file? Typing = shows the line numbers currently in view, but does not show how many lines are in the file. I'm not looking for a clickable scrollbar, but just a visual indicator of how close I am to the beginning or end of the man page.
2 Answers
@Marcus Muller is correct that less needs to know the file size before it can give a percentage location indicator. Other than pre-determining the file size, another method is to force less to read all the input at startup. One way to do this is to ask less to go to end-of-file, then go to start-of-file.
In bash:
$ export PAGER='less +G1G -P"%Pb\%"'
$ man man
MAN(1) FreeBSD General Commands Manual MAN(1)
NAME
man – display online manual documentation pages
SYNOPSIS
[ ... ]
behavior. Overrides the MACHINE_ARCH and MACHINE environment
30%
My testing shows this isn't a perfect solution, but it's close, so perhaps someone more knowledgeable than I can refine it further.
So, by default that's impossible, less needs to know how long the input is before it calculates how far you're in. But: less has an option --file-size, which counts the length of the file as it's loaded. It doesn't do that by default because maybe there's text files for which that reading takes a long time.
Well, man pages typically don't belong in that category. For some reason, man still calls less without --file-size.
No big deal,
export MANPAGER="less --file-size"
solves that problem :)
-
With
export MANPAGER="less --file-size"I getThere is no file-size option.Rich006– Rich0062023-04-18 16:27:38 +00:00Commented Apr 18, 2023 at 16:27 -
1@Rich006 oh!
less --versionsays what?Marcus Müller– Marcus Müller2023-04-18 16:59:04 +00:00Commented Apr 18, 2023 at 16:59 -
less --versionsaysless 581.2 (POSIX regular expressions)Rich006– Rich0062023-04-18 17:36:29 +00:00Commented Apr 18, 2023 at 17:36 -
@Rich006 interesting! my 590 has that, so that must really be a rather new development. In that case, go for Jim's answer. Should work.Marcus Müller– Marcus Müller2023-04-18 17:46:36 +00:00Commented Apr 18, 2023 at 17:46
=? Don't you see something likelines 3-24/1000 byte 63/3893 2%?less. That's why my original question (before editing) asked aboutless.