export LESS="-m"
More generally, the LESS
environment variable may contain options equivalent to command line flags you could explicitly pass when running less
-- here, the -m
option that tells it to prompt more richly (including the percentage, as you asked). You could pass also more than one option within that single environment variable by ending each with a $
. For much more info, see less's manpage.
Edit: it is of course possible (depending on how you're using less, e.g. if you're piping to it rather than calling it on a file) that less doesn't know the total size it will be displaying, in which case of course it can't show the % -- in that case it will prompt with what little info it does have, e.g., how much text has it shown so far. For example, man
does use less
that way, by piping.
So, if your specific need is to see the % in man
(rather than when calling less
directly on a file) you need to use an "alternate pager" (environment variable MANPAGER
or switch -P
on the man
command line) which is a simple script that saves man
's output to a temp file and then uses less
on the latter. (That may lose man's own "colorization" unless you play yet further and deeper tricks, etc, etc -- similarly you might use the "preformat pages" option of man
and uncompress such a preformatted page to a tempfile on which to run less
, etc, but this is starting to become a somewhat complex "simple script";-).