10

less(1), the terminal file pager, seems to be missing lesskey(1) and the ability to rebind the keystrokes in less. The docs claim it's there, but it doesn't work. Am I crazy or is Apple's version of less broken?

$ less -k ~/.less /etc/fstab
There is no -k option ("less --help" for help)
$ less --help | grep lesskey
  -k [file]  .  --lesskey-file=[file]
                  Use a lesskey file.
$ which lesskey less
/usr/bin/less
$ less --version | head -2
less 418
Copyright (C) 1984-2007 Mark Nudelman

I'm running Lion. It seems odd that Apple would mess with less(1) at all, it's such an old and standard Unix utility. (Less compiles easily from sources on MacOS, so I'm now using my own version.)

1

1 Answer 1

13

The Lion build of less indeed comes with the lesskey feature disabled, as can be seen by the customized defines.h it is being built with (line #define USERFILE 0). This doesn't mean it's broken, just that someone decided to customize the build and disable this feature for whatever reason. Sadly they neglected to update the man page, which is why it's still referring to it.

If you want this feature, building your own less from source is just a matter of ./configure && make install (which puts it into /usr/local), and you might also want to get a more recent version while you're at it.

4
  • 4
    Homebrew if you brew install less actually recommends the package homebrew/dupes/less which installs version 458 and has working lesskey. Much less work than manually building.
    – Steven Lu
    Commented Apr 26, 2016 at 18:45
  • So the problem that I have now on High Sierra is that I do use homebrew's less which works right, but man does not use this one. It uses system less... Not really sure what to do. I might modify it so the homebrew less becomes symlinked as /usr/bin/less, but it sounds invasive. Actually: I can't even do it, probably protected by SIP.
    – Steven Lu
    Commented Dec 19, 2017 at 5:10
  • 2
    @StevenLu man man says that you can override this by setting PAGER or MANPAGER in your environment. Commented Dec 20, 2017 at 8:51
  • Yes, I’ve added that to my shell config and it works.
    – Steven Lu
    Commented Dec 20, 2017 at 10:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .