1
1
I'm trying to use less
's lesskey
-file support, as described in the manpage:
KEY BINDINGS
You may define your own less commands by using the program lesskey (1)
to create a lesskey file. This file specifies a set of command keys
and an action associated with each key. You may also use lesskey to
change the line-editing keys (see LINE EDITING), and to set environment
variables. …
Unfortunately, this isn't working for me:
$ mkdir test_lesskey && cd !#:1
$ less --version
less 471 (PCRE regular expressions)
Copyright (C) 1984-2014 Mark Nudelman
$ cat <<-EOF >a_lesskey
#env
LESS=-?
EOF
$ lesskey -o a_dot_less 'a_lesskey'
$ less -FX a_dot_less
^@M+Gc^@^@e^@^@v ^@LESS^@84-?^@xEnd
$ less --lesskey-file=a_dot_less "~/.profile"
At this point, less
is opened normally, instead of printing the less -?
usage-text and quitting as expected.
I've experimented with a couple different flags (and formattings), and none of them seem to work as described in the manpage.
The lesskey mechanism overall definitely works; I can define, say, the following:
#command
e quit
… and less
will exit, as expected, if I hit the e key. It's only the environment-variable section that I cannot make work as-expected.
I've tried this on both Arch (pacman -S less
) and OS X (brew install less
; it's irrelevant on an out-of-the-box OS X, as the OS X less
is patched not to include lesskey
support.)
I e-mailed the developer, with a link to this thread. We'll see if he has a solution for me! (= – ELLIOTTCABLE – 2015-12-10T03:53:15.953
For now, I simply did as you suggest: Moved the actual keys in the lesskey into
– ELLIOTTCABLE – 2015-12-10T03:53:57.457~/.less
, compiled them to~/.lesskey
, and then moved all the environment-configuration into my~/.profile
with a caveat that I'm only doing so because it's broken.I already mailed him last month and was told, he'll look into it — I don't see it in the list of known bugs though.
– 1.61803 – 2015-12-10T10:38:14.077Also, I think you're using the defaults the other way around.
lesskey
will take~/.lesskey
and output~/.less
. You can also useLESSKEY
orLESSKEY_SYSTEM
vars. I suggest you check theman
page for further details.