function discoverOriginalPrice(discountedPrice, salePercentage) {
var originalPrice = discountedPrice / (1 - (salePercentage * .01));
return +originalPrice.toFixed(2);
}
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";-).
I have this in my environment. It'll print
at the bottom, or at least as much of that information as it has.
export LESS='-P?f%f - .?ltLine?lbs. %lt?lb-%lb.?L of %L.:?pt%pt\%:?btByte %bt:-...'
To add to Alex Martelli' answer:
Note that you can also pass any command line parameter to less at runtime, by just typing it (including the -), followed by enter key. So you can just type
-m<Enter>
into a running less to toggle the long prompt.
This is especially useful for options that need to be changed at runtime, e.g. -S (line folding on/off).