Why does .lesshst keep showing up in my ~
Asked Answered
A

6

29

I never use less, and have always used more. It is what I was introduced to, which is probably why I use more more instead of using less more. ( Sorry, that is going to sound a bit of a mess :) )

I just tried less and couldn't even quit out of it, until I realized it took a vi/vim style command. At least, I believe that is what happened.

By in ~ there is always a .lesshst file, which I rm all the time, as I would prefer to use more or nano for simple stuff and I can use TextMate for simple text editing, or Sublime or whatever else I am in the mood for.

I also just noticed ".jbapps-myusername" is in ~ now as well. This showed up 2 days ago, and I don't recall installing anything strange. Any idea what it is? I have never jailbroken my phone, and don't install hacks on my machine. Those things that do go into that grey area are getting played with in a VM, not on the core of the machine I am working on as my main computer.

$file .jbapps-haneda 
.jbapps-haneda: ASCII text, with no line terminators

The contents of the .jbapps-* file are "483^@" with no leading or trailing newlines, carriage returns etc.

Then there is my git issue. I have a .config directory, inside it is a "git" dir, which inside that is a file called "ignore", which as far as I can tell, is near identical to .gitignore_global. Did git create .config, or is this a convention that other apps use as well?

That brings me to my final issue, in ~ I have .gitignore_global, .gitconfig, and also .config/git/ignore

Seems a mess to me, I would love to mv .gitignore_global .gitconfig .config/git Is there a config somewhere that I can define these locations? It's all just a mess of dot files, it would be so much nicer if ~ simply had .config and all the dot files were in there. I can live with .ssh as it is a directory, so there is at least an effort to not litter my home dir. But raw dot files kind of get in my way. I know I can ls -l and not show the dot files, but I think seeing all your files all the time is a good way to learn what has been created that you might not be aware of.

Thank you.

Suggestions?

Allow answered 5/10, 2014 at 1:59 Comment(0)
P
13

FIlenames starting with . are (lightly) hidden files. They're often use by programs to record configuration or usage information. Sometimes that's recorded from the last time you used the program; that's the case with less and the .lesshist "history" file.

If you aren't sure which program created the file, a websearch will usually answer the question... so I'm leaving understanding the rest of those files as an Exercise For The Reader.

Pantheism answered 5/10, 2014 at 3:2 Comment(5)
And I take it there is no system level config that says "store dot files: ~/.config" or similar, to take away some of the mess, with perhaps over-rides to "store specific files: ~"? Spring is near, and I am looking to clean house :)Allow
Unfortunately, each application decides where it wants to keep its own configuration. There are several conventions for this, but the home directory is one of the standard locations.Pantheism
How would I go about finding what app used less, it was not me. I am tempted to chmod it so it can't run, but I have a feeling some installer scripts may rely on it, which I find crazy, they should use a conned than can only be configured by flags, not some config file that will fail if it is not just as they had theirs.Allow
One command that uses less is man. If you use more, you've probably used man as well, hence . lesshst existence.Photochromy
Broken link An error has been encountered in accessing this page. Till
N
12

You can disable the creation of the ~/.lesshst file by setting the LESSHISTFILE variable to -.

export LESSHISTFILE=-

You can also set the above to another valid file path to have the less command use that file instead. I like to do the following in my ~/.zprofile (~/.profile for non-zsh users) file:

export LESSHISTFILE="$XDG_STATE_HOME"/less/history

As for your git stuff, Git probably wasn't the program that created the ~/.config folder. That folder is part of the XDG Base Dirs specification, and git actually respects this specification. In short all you need to do is:

  • mv -T ~/.gitconfig $XDG_CONFIG_HOME/git/config
  • mv -T ~/.gitignore_global $XDG_CONFIG_HOME/git/ignore

Also see Arch Wiki for XDG Base Directory


Finally, for the other files you notice, unfortunately many developers are not aware of where to put various files, so they end up just using the hidden folder/files method to place stuff in the user's home directory. The Arch Wiki actually has a section that tracks these things. Feel free to report any programs you find that are misusing the hidden folder/files trick.

Neogaea answered 8/2, 2021 at 8:15 Comment(5)
For example in ~/.bashrc, see also askubuntu.com/questions/386311/…Zirconia
Just noting here that per the spec, XDG_STATE_HOME would be more appropriate for history files: "$XDG_STATE_HOME ... may contain: actions history (logs, history, recently used files, …)"Enright
@JakeRomer this is my first time hearing of XDG_STATE_HOME. Is that new?Neogaea
I think it's relatively a new addition — I can't find a changelog for the spec but I notice that the rust-xdg library only recently added support for it and hasn't released it yet.Enright
How do I disable in Windows?Leucoma
O
9

A .lesshst file will be generated in one’s home directory if one uses the man command to view documentation; performs a search within such documentation by using the / key, typing a search term, and pressing the Enter key to begin a search; and subsequently exits the man command documentation using the q key.

Apparently, one can use the data in this file to perform a man command search using the last used search term the next time one uses the man command to view documentation. (This would be accomplished by pressing the search key combinations N or Shift+N after having generated a .lesshst file.) It's not clear to me what the benefit of storing search terms preceding the last is though.

Orbadiah answered 29/11, 2019 at 6:51 Comment(0)
I
3

I just looked into that this morning. Because of my OCD, I wanted to move the .lesshst file from my $HOME and put it in my $XDG_LOG_HOME.

For less:

I created a lesskey-file in $XDG_CONFIG_HOME called "lesskey", in this lesskey-file, I set the LESSHISTFILE environment variable to the path of my future less-history-file (in $XDG_LOG_HOME). If you already have a lesskey just add to it. Then in my zshrc (or bashrc) I set the following line :

alias less='less --lesskey-file=$XDG_CONFIG_HOME/lesskey'

That does the trick only when using less

For man:

I put the following line in my zshrc (or bashrc):

alias man='man --pager="less --lesskey-file=$XDG_CONFIG_HOME/lesskey"'

That does the trick with man ! I tried to use more but it does not seem to generate a .lesshst in $HOME

Interception answered 28/10, 2020 at 11:50 Comment(2)
Any advantage using this approach over directly setting LESSHISTFILE in ~/.profile or similar?Fist
What is XDG_LOG_HOME? It appears to be non-standardNeogaea
K
1

You may be using less without knowing it. From the man page:

COMPATIBILITY WITH MORE
   If the environment variable LESS_IS_MORE is set to 1, or if the program is invoked via a file link
   named "more", less behaves (mostly) in conformance with the POSIX  "more"  command  specification.
   In this mode, less behaves differently in these ways:

   The  -e  option  works differently.  If the -e option is not set, less behaves as if the -E option
   were set.  If the -e option is set, less behaves as if the -e and -F options were set.

   The -m option works differently.  If the -m option is not set, the medium prompt is used,  and  it
   is prefixed with the string "--More--".  If the -m option is set, the short prompt is used.

   The  -n  option  acts  like the -z option.  The normal behavior of the -n option is unavailable in
   this mode.

   The parameter to the -p option is taken to be a less command rather than a search pattern.

   The LESS environment variable is ignored, and the MORE environment variable is used in its place.
Kmeson answered 7/5, 2019 at 9:19 Comment(0)
M
0

Command git config --list use program LESS.

Manard answered 4/1 at 21:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.