0

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.

5
  • What do you see with =? Don't you see something like lines 3-24/1000 byte 63/3893 2%? Commented Apr 18, 2023 at 15:54
  • 1
    I have edited the question to focus specifically on man pages. Viewing a regular text document, I do see the percentage as you suggest. Viewing a man page, I do not. Commented Apr 18, 2023 at 15:56
  • OK, please also update your title since "scrollbar thumb" doesn't really mean anything (does it?) and make sure to tell us what operating system you are using. Commented Apr 18, 2023 at 15:59
  • Please edit your question to indicate what pager you are using. Commented Apr 18, 2023 at 16:10
  • I'm willing to use a different pager, so far I've used the default pager less. That's why my original question (before editing) asked about less. Commented Apr 18, 2023 at 16:29

2 Answers 2

1

@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.

1

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 :)

4
  • With export MANPAGER="less --file-size" I get There is no file-size option. Commented Apr 18, 2023 at 16:27
  • 1
    @Rich006 oh! less --version says what? Commented Apr 18, 2023 at 16:59
  • less --version says less 581.2 (POSIX regular expressions) Commented 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. Commented Apr 18, 2023 at 17:46

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.