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

Folder-local options for the file manager #623

Open
1 task done
jyothisv opened this issue Feb 3, 2024 · 2 comments
Open
1 task done

Folder-local options for the file manager #623

jyothisv opened this issue Feb 3, 2024 · 2 comments
Labels
feature New feature request

Comments

@jyothisv
Copy link

jyothisv commented Feb 3, 2024

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?

  • Yes, I'll give it a shot

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:

[[directory_local_settings]]
directory = "~/Downloads"
sort_by = "modified"
sort_reverse = true

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

@jyothisv jyothisv added the feature New feature request label Feb 3, 2024
@sxyazi
Copy link
Owner

sxyazi commented Feb 5, 2024

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.

@tianze0926
Copy link

tianze0926 commented May 6, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

No branches or pull requests

3 participants