-
Notifications
You must be signed in to change notification settings - Fork 460
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
Folder-local options for the file manager #623
Comments
Sounds good to me. Maybe we can have: [folder]
rules = [
{ name = "Downloads/", sort_by = "modified", sort_reverse = true, preload = false, ... }
] to keep the same style as others. |
With the introduction of DDS I can now achieve a basic version using the plugin system: -- ~/.config/yazi/plugins/folder-rules.yazi/init.lua
return {
setup = function()
ps.sub("cd", function()
local dir = tostring(cx.active.current.cwd)
if string.find(dir, "Downloads") then
ya.manager_emit("sort", { "modified", reverse = true, dir_first = true })
else
ya.manager_emit("sort", { "alphabetical", reverse = false, dir_first = true })
end
end)
end,
} -- ~/.config/yazi/init.lua
require("folder-rules"):setup() But I’m uncertain about how much overhead there would be compared to when it’s implemented in Rust. |
I disagree with the proposed direction of adding directory-specific settings directly into the configuration file for several reasons:
Inspired by GUI file managers, a better approach is to make the currently stateless, globally-affecting sort shortcuts folder-specific and stateful. These states could be stored in a dedicated state directory, such as Example [
{ "name": "~/Downloads/", "sort_by": "modified", "sort_reverse": true }
] This method provides a clearer separation of concerns, enhances convenience, and protects user privacy. This is one possible improvement over the current proposal, though it might not be the only or the best solution, and further refinement could still be beneficial. |
With the introduction of DDS, I think this is now well-supported. I've added it to the Tips page of the documentation, https://yazi-rs.github.io/docs/tips/#folder-rules, based on a code snippet shared by @tianze0926 - thank you for sharing it! This approach is more flexible because you can call all Yazi-supported commands in Lua, not just And there's no impact on performance - these commands skip unnecessary computations and use cached results. For example, if you set directory |
I'm going to lock this issue because it has been closed for 30 days. ⏳ |
Is your feature request related to a problem? Please describe
First of all, thank you very much for this awesome project! I am impressed by Yazi's speed as well as features. I currently use lf and would love to switch over.
One feature that I really like in lf is the ability to set properties only in a specific directory. For example, we can use time-based sorting for say the Downloads directory while keeping natural sorting for all other directories. I think that would be a a nice addition to Yazi.
Will you be willing to contribute this feature?
Describe the solution you'd like
There should be an option to specify directory-specific settings in
yazi.toml
. Probably we can add a list of directory, settings table under the[manager]
.An example:
If the directory name ends with a slash, the settings would be applied to its sub-directories as well.
A related feature would be a global option to make sorting commands always be directory-local. Usually, when I sort the files in a directory, I don't want the sorting to persist when I go to the parent directory. So this option would be quite useful to me.
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: