Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ignore files #350

Closed
1 task
musjj opened this issue Nov 8, 2023 · 7 comments
Closed
1 task

Support ignore files #350

musjj opened this issue Nov 8, 2023 · 7 comments
Labels
invalid This doesn't seem right

Comments

@musjj
Copy link
Contributor

musjj commented Nov 8, 2023

Is your feature request related to a problem? Please describe

It'd be nice to be able to automatically hide files in ignore files

Will you be willing to contribute this feature?

  • Yes, I will try to implement it

Describe the solution you'd like

Support ignore files. There's this snippet from man fd describing the types of ignore files that might be useful to support:

-I, --no-ignore
       Show search results from files and directories that would otherwise be ignored by

       • .gitignore

       • .git/info/exclude

       • The global gitignore configuration (by default $HOME/.config/git/ignore)

       • .ignore

       • .fdignore

       • The global fd ignore file (usually $HOME/.config/fd/ignore )

       The flag can be overridden with '--ignore'.

I think supporting at least .gitignore and .ignore would be reasonable.

Describe alternatives you've considered

No response

Additional context

No response

@musjj musjj added the feature New feature request label Nov 8, 2023
@sxyazi
Copy link
Owner

sxyazi commented Nov 9, 2023

We already have a FR of "Hide specified files or directories" noted in #51.

But I don't want to impl it through .gitignore way, it will make things get complicated -- which needs iterator all parent directories recursively, ex: ~/a/b/c results in ~/a/b/.gitignore, ~/a/.gitignore, and ~/.gitignore to be found. That's a rather inefficient approach, I prefer to configure them in a certain place.

@musjj
Copy link
Contributor Author

musjj commented Nov 9, 2023

Is it really that inefficient? It only needs to check and parse ignore files in the 2-3 visible panes right? fd does this and it's still the most efficient file list tool all around.

@Hanaasagi
Copy link
Contributor

I see ranger using a global regex to filter them. e.g.

# Which files should be hidden? (regular expression)
set hidden_filter ^\.|\.(?:pyc|pyo|bak|swp)$|^lost\+found$|^__(py)?cache__$

@sxyazi
Copy link
Owner

sxyazi commented Nov 29, 2023

Is it really that inefficient? It only needs to check and parse ignore files in the 2-3 visible panes right? fd does this and it's still the most efficient file list tool all around.

Due to the necessity of recursively collecting all .gitignore files before actually loading the file list, this will become the sole synchronous blocking factor for Yazi at present, especially for slower devices or network storage.

Introducing additional caching mechanisms is also required for this, necessitating an appropriate cache invalidation strategy.

Maybe we could collect .gitignore while loading the file list and apply these filters to the list once it's gathered, but this would make it more complex and result in list flickering.

I see ranger using a global regex to filter them. e.g.

# Which files should be hidden? (regular expression)
set hidden_filter ^\.|\.(?:pyc|pyo|bak|swp)$|^lost\+found$|^__(py)?cache__$

Yea that would be an ideal approach, we could expand it further though

@Linus789
Copy link
Contributor

I see ranger using a global regex to filter them. e.g.

# Which files should be hidden? (regular expression)
set hidden_filter ^\.|\.(?:pyc|pyo|bak|swp)$|^lost\+found$|^__(py)?cache__$

Yea that would be an ideal approach, we could expand it further though

Besides global filtering, I think it would be nice to have a way to hide files in specific directories, too. For example, Nautilus, Dolphin and Thunar use the .hidden file (https://fosspost.org/hide-files-folders-linux/) which only needs to be read for the current folder. If this would be the correct design choice for yazi however, I don't know.

@sxyazi
Copy link
Owner

sxyazi commented Feb 10, 2024

This FR is already been in Feature Requests, closing in favor of that list

@sxyazi sxyazi closed this as not planned Won't fix, can't repro, duplicate, stale Feb 10, 2024
@sxyazi sxyazi added invalid This doesn't seem right and removed feature New feature request labels Feb 10, 2024
Copy link

I'm going to lock this issue because it has been closed for 30 days. ⏳ This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

4 participants