-
Notifications
You must be signed in to change notification settings - Fork 686
Add ignore functionality to Yazi based on gitignore and user overrides #3257
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
Conversation
- Introduced `Ignore` actor to manage ignore patterns based on gitignore and user-defined overrides. - Implemented `IgnoreFilter` to handle ignored paths and patterns. - Updated `Files` struct to include an ignore filter, allowing files to be filtered based on ignore rules. - Modified existing actors and managers to apply ignore filters during file operations. - Updated `Cargo.toml` and `Cargo.lock` to include new dependencies related to ignore functionality.
|
Docs for this PR have been added at yazi-rs/yazi-rs.github.io#294 |
|
Sorry! There are no plans to support gitignore because it conflicts with another planned, more general file hiding feature, #694, which is more easier to extend to the virtual file system. Ideally, I want to avoid having multiple implementations for similar features to reduce maintenance costs. Next time, it would be very helpful to open a discussion first to see if it aligns with the project goals to avoid any risks of re-work 👍 Lines 142 to 144 in 46569a1
Thank you for the effort, @carlosedp! |
|
I've submitted this because I saw most the proposals or previous discussions were almost 1 year old and didn't have updates since... |
Yeah there hasn't been much progress on it so far - no one has been able to work on it yet, unfortunately. If you're interested in it, feel free to open a new discussion! |
|
What if I kept the gitignore flag and transform the overrides into the more granular way you mentioned in the issue: I feel this could work for both cases... one which people can hide all that's ignored and the other for people who want to define the hiding... |
|
Because I feel what I implemented already does a similar thing but in a more generic way that you can override the hiding in a global manner. |
|
What I have in mind is something like this: # yazi.toml
[files]
excludes = [
# SFTP
{ urn = "*.tmp", in = "sftp://**" },
# Search results
{ urn = "/root/**/*.pyc", in = "search://**" },
# Regular
{ urn = [".{git,DS_Store}", "__pycache__"], in = "/code/**" },
# Fallback
{ urn = ".DS_Store", in = "*" }
]
in which:
There are paired options We can also provide a built-in command or a Lua API to allow loading other ignore rules from external sources so that users can subscribe to the LF (a file manager) has a good example with its cmd on-cd &{{
if [ "$PWD" = "/foo" ]; then
lf -remote "send $id set hiddenfiles \"*mp4\""
elif [ "$PWD" = "/bar" ]; then
lf -remote "send $id set hiddenfiles \"*pdf:*txt\""
else
lf -remote "send $id set hiddenfiles \".*\""
fi
}} |
|
Hi @sxyazi , would you reopen this as I've changed the implementation to follow the patterns as you explained above? |
|
I also updated the docs to match the changes here: yazi-rs/yazi-rs.github.io#294 |
|
Actually I've reopened the PR with new code here: #3266 |
This pull request introduces a new ignore filtering system to the file manager, adding support for
.gitignoreand custom ignore patterns. It enables users to control which files and directories are hidden from view, either by leveraging Git ignore rules or specifying their own patterns. The changes span configuration, core logic, and integration with the actor and file management systems.Key changes include:
Ignore Filter System Implementation
IgnoreFilterstruct and logic inyazi-fsto support filtering files and directories based on Git ignore rules and user-defined patterns. This includes methods to build filters from a directory or patterns and to check if files should be ignored.Filesstruct to store and apply anIgnoreFilter, ensuring ignored files are dynamically filtered out during file operations.Cargo.tomlforgit2andignorecrates to enable Git ignore and pattern matching functionality. Thegit2library is used on apps like eza to provide a similar functionality.Configuration and Integration
[mgr]) to includegitignore_enableandignore_overridesettings, allowing users to toggle Git ignore integration and specify custom ignore patterns.Ignoreactor inyazi-actorto manage ignore filter application based on configuration, and integrated it into the folder refresh and directory change workflows.Sample configuration:
Command and Event Handling
ignoreaction, ensuring it is properly dispatched and executed in response to relevant events.Module Organization
ignoremodule in the appropriate places to ensure correct linkage and initialization across the codebase.These changes collectively add robust and flexible ignore filtering, enhancing the file manager's ability to hide unwanted files and directories according to user preferences and project standards.