lsd-rs / lsd

The next gen ls command
Apache License 2.0
13.54k stars 439 forks source link

Option to filter VCS ignored files #218

Open augustobmoura opened 5 years ago

augustobmoura commented 5 years ago

Similar to rg and fd, add a option to ignore paths in .gitignore, .ignore, .svnignore etc. It's really useful with the --tree option (maybe it should be active by default?)

We can use https://crates.io/crates/ignore as the mentionated libaries. I might make a pull-request about it this weekend, should be easy to plug the ignore lib in

Peltoche commented 5 years ago

Hi @augustobmoura ,

It seems a cool feature indeed. You PR will be welcomed!

meain commented 5 years ago

I don't think having it active by default is a good idea as it might conflict with people who wanna use lsd as an alternative to ls. But having this feature under a flag would be awesome.

augustobmoura commented 5 years ago

Turns out that the implementation is not as easy as I imagined (it's like a habit to me). The ignore crate works with a custom path walker and customs structs for representing files and directories, so probably we will need to rewrite a lot of code. I don't have much time to work on it, and probably a regular maintainer should be responsible for a refactor of this scale

sangdth commented 5 years ago

Looking forward into this feature, as sometimes I want to list the tree but want to ignore the node_modules folder.

texastoland commented 4 years ago

Is it feasible now that @sumitsahrawat dropped #275? It'd also be helpful to pass --ignore-file to my alias like fd too. ripgrep's ignore crate provides a lot of that out of the box. My workaround is:

alias tree='lsd --tree $(xargs printf " --ignore-glob=%s" < $IGNORE_FILE/ignore)'
jrd commented 1 year ago

Here is mine:

alias lt='lsd --tree $(IGNORE=$(git rev-parse --show-toplevel)/.gitignore; if [ -f "$IGNORE" ]; then xargs printf " --ignore-glob=%s" < "$IGNORE"; fi)'