5

I use the less command a lot to view files, but when viewing a file, sometimes accidentally I type the s key within less, activating then the log feature. If I don't notice that log in the bottom of the terminal and keep typing (such as searching for a pattern), a file may be created in the current directory.

According to man less, there is a "secure" mode for less, when the environment variable LESSSECURE is set to 1, but this will disable several more features, I only want to disable the log feature.

I never use the log feature in less. How can I disable the log feature of less?

7

Create a file setting a new key binding for the s command key, and "compile it" as follows:

echo 's invalid' >~/.lesskey
lesskey

Then typing s in less will just beep or flash.

  • Yes it works as expected, but I created an alias in my .bashrc, so my less is actually less -RM -s +Gg, so I'm wondering if the making-s-invalid can be set into the alias, since I have to type commands and compile the file into another file ~/.less if using your solution. – CodyChan Jun 30 '15 at 9:11
  • I dont think you can make it an option to the less command. But you only need to run lesskey once. Why not add it in your ~/.bash_profile if you dont want to forget it. You can specify a different place for the .less file. – meuh Jun 30 '15 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.