Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
24
rated 0 times [  24] [ 0]  / answers: 1 / hits: 12097  / 2 Years ago, mon, march 21, 2022, 12:11:45

Every time I search for a term in less, it stores my search in the file .lesshst. How can I stop this behavior?


More From » less

 Answers
2

Open a terminal and create a file .lesskey, in your home folder and append the following to it:


#env
LESSHISTSIZE=0

If you already have the file .lesshst in your home folder, then delete it and type the command


lesskey

You shouldn't get any errors here. This will not store any history of less from now on, until you change the .lesskey file.


From the man page of less:



ENVIRONMENT VARIABLES


   Environment variables may be specified either in the system environment
as usual, or in a lesskey (1) file. If environment variables are
defined in more than one place, variables defined in a local lesskey
file take precedence over variables defined in the system environment,
which take precedence over variables defined in the system-wide lesskey
file.

LESSHISTSIZE


          The maximum number of commands to save in the history file.  The
default is 100.


EDIT:


From the comments, I found a better way to prevent having a history file for less.


In the .lesskey file in the home folder, append this:


LESSHISTFILE=-

or


LESSHISTFILE=/dev/null

If you put this in your ~/.bashrc file, this will work, but will have a lower precedence if you have other values in your .lesskey file for the same variables.


You may want to have a look at this:



[#28122] Monday, March 21, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
otatorm

Total Points: 218
Total Questions: 113
Total Answers: 124

Location: British Indian Ocean Territory
Member since Tue, Feb 22, 2022
2 Years ago
;