Stupid less (1)
trick
Do you get tired of reading a man
page, or even
perldoc
, for cryin' out loud, and having to deal with the
POSIX regex engine instead of something more powerful and Perl-like? I
know I do. Every time I type /^[[:space:]]+something
,
instead of /^\s+something
, it just makes me sick. Something
ought to be done about this nonsense.
Well, after saying something like this to myself for the umpty-jillionth
time, I decided to look into it.
It turns out that less
can be rebuilt from source fairly easily (at least, on a *nix-like system -- see its home page for details), and one of the configuration options is the choice of regex engine. The build was complicated a bit by the fact that my *nix-like system is Mac OS X, so I had to link against the MacPorts version of pcre.
The actual configuration invocation used was
$ env CFLAGS=-I/opt/local/include \ ./configure --with-editor=vim --with-regex=pcre
with the 'env' invocation simply so that the configuration script could find the MacPorts include files. As you see, I got wild and also configured 'vim' rather than 'vi' as the editor.
By default the rebuilt less
installs in /usr/local/bin
. I had no problem with this, but I was reluctant to supersede the system's less
until I had played around some more. So I modified the Makefile
to install it as lessp
, and edited less.nro
(the man
page) appropriately, before I ran
$ sudo make install
After further thought, I also got rid of the lessecho
and lesskey
that also get built.
It turns out that both man
and perldoc
pay attention to the PAGER
environment variable, so that's the way I'm controlling which pager gets used at the moment.
Any resident of the United States who remembers "A Few Minutes With Andy Rooney" will recognize the style of the first paragraph, and read it in the right tone of voice. For people who don't, I have no real substitute. But Andrea Camilleri fans can imagine Pippo Ragonese, but less sanctimony and more pure whine.
Leave a comment