lsd icon indicating copy to clipboard operation
lsd copied to clipboard

Treat items starting with '_' the same as files starting with '.' and ignore them.

Open Terraphice opened this issue 3 years ago • 15 comments

A relatively uncommon but still popular method of marking files to be ignored is beginning them with '_' instead of '.'.

VIM does this, with the _viminfo file, less does this for the _lesshist file, etc. It's pretty uncommon, but it's also really uncommon to begin files/directories with '_' in the first place.

I'd like to see this prefix added alongside '.' and ignored like it is in exa. It's the only thing exa does differently that I really want in lsd.

Example: image

Terraphice avatar Oct 12 '22 10:10 Terraphice

I don't think that is something we would want in lsd as this would make us deviate from what gnu ls does. Do you have some links pointing to docs in exa where they mention hiding filenames starting with _?

meain avatar Oct 12 '22 11:10 meain

I don't really feel like digging through docs. Here's the difference in action though: image

Terraphice avatar Oct 12 '22 11:10 Terraphice

maybe we can did this for windows, seems like a windows feature/common used case

https://stackoverflow.com/a/63516223/4242336

zwpaper avatar Oct 25 '22 07:10 zwpaper

That is pretty interesting. I guess we can consider hiding _ by default.

meain avatar Oct 25 '22 07:10 meain

Any updates to this issue that I might have missed? It's been quite a while and this issue was never revisited.

Terraphice avatar Sep 08 '23 21:09 Terraphice

/help /good-first-issue /milestone v1.1.0

zwpaper avatar Sep 19 '23 03:09 zwpaper

@zwpaper: This request has been marked as suitable for new contributors.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed by commenting with the /remove-good-first-issue command.

In response to this:

/help /good-first-issue /milestone v1.1.0

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

muniu-bot[bot] avatar Sep 19 '23 03:09 muniu-bot[bot]

we could hide _ prefixed file ONLY in windows by default, and add a flag to control this.

ref: https://man7.org/linux/man-pages/man1/ls.1.html

       --hide=PATTERN
              do not list implied entries matching shell PATTERN
              (overridden by -a or -A)

zwpaper avatar Sep 19 '23 04:09 zwpaper

I was looking at working out how to implement this as a first issue. The easiest way would surely just be to have the following in the config file by default on Windows:

ignore-globs:
    - _*
#   - .git

However, ignored globs given here or by using the -I flag currently can't be overidden by using the -a flag. Shouldn't -a take precedence over -I?

Furthermore, this of course only works if a config file is present with that option, and at least for me, no config file was generated upon installation and I had to manually create it myself. Isn't it desirable to automatically create the config file when lsd when it is run for the first time? If this was the case, that option could simply be included in the config file by default on Windows and not otherwise.

matterhorn103 avatar Nov 06 '23 15:11 matterhorn103

As a Windows user, I'd be very surprised if this behaviour were enabled by default. It would seem very weird to me if, e.g. __init__.py files were being hidden. I get the vim use case and I understand making it configurable but I feel it should be something users choose to opt-in to as it's a niche non-standard thing that most people won't even be aware of.

ChrisDenton avatar Nov 06 '23 17:11 ChrisDenton

This seems like a really bad idea to implement automatically, I don't know any other program that does this on Windows, other than VIM which isn't exactly a Windows native program. Preferably just leave it to the users to use "ignore-globs"

ofersadan85 avatar Jan 02 '24 11:01 ofersadan85

Yeah I don't particularly care whether it's automatic or not, I just think the feature should be there in some capacity, especially if you want feature parity with exa/eza or whatever.

Terraphice avatar Jan 02 '24 20:01 Terraphice

So in other words, you suggest using "ignore-globs" for ignoring paths, but when doing -a (which implies show everything) the ignores should not be used. Is that right? @Terraphice ? I think this makes sense, especially since we already have the middle ground of using -A which shows "almost everything" so that should ignore what the user wanted to ignore, but -a wouldn't.

If @zwpaper / @meain support this, I'll happily write a PR for this

ofersadan85 avatar Jan 03 '24 06:01 ofersadan85

yes, IMHO just like the GNU ls support --ignore and --hide, we should also impl that and leave the choice to users, they could add any globs to the configuration file if they like.

and we are not setting any default values even in Windows.

please notice,

  • --ignore will NOT be overwritten by -a or -A
  • --hide will be overwritten by both -a and -A

thanks so much if anyone could help @ofersadan85

zwpaper avatar Jan 03 '24 11:01 zwpaper