1

This is a follow up on How to make the 'less' command handle UTF-8?

If I want to set options for less globally, so that each user doesn't have to fiddle with their own env vars (.basrc, etc) individually, where should it be set?

/etc/bashrc is not a good option as then I'd have to set one up for each shell.

The man page for less mention a lesskey file that has a #env section where i can set this, but there is no mention of where to put it. It does mention that I can use env vars LESSKEY_SYSTEM and LESSKEY to point to the file... but that creates a chicken vs egg problem.

Other distros man pages mention /usr/local/etc/sysless but that is not used on ubuntu from my tests.

gcb
  • 253
  • 3
  • 16

1 Answers1

2

strace to the rescue.

open("/usr/bin/.sysless", O_RDONLY)     = -1 ENOENT (No such file or directory)
open("/etc/sysless", O_RDONLY)          = -1 ENOENT (No such file or directory)
open("/home/user/.less", O_RDONLY)      = -1 ENOENT (No such file or directory)
open("/home/user/.lesshst", O_RDONLY)   = 3

/usr/bin/.sysless is very odd. let's skip that. /etc/sysless sounds more sane. I think this is the answer. I can't say for sure because now less gives me

Cannot use lesskey file "/etc/sysless"

Still need to debug that since the contents of that file for now are copied from the man page...

gcb
  • 253
  • 3
  • 16
  • The lesskey file (binary) needs to be build with lesskey(1) command. Assuming you saved your text input file as `~/.lesskey` you can install it system-wide with `lesskey -o /etc/sysless` – pmartycz Jun 30 '22 at 14:18