twpayne/chezmoi

Manage related files by logical group

Closed this issue · 5 comments

mjkx5 commented

Is your feature request related to a problem? Please describe.

I do not know how to fastly find history about any package file, eg: bat, htop ... .

Describe the solution you'd like

maybe add package_name to specify domain about directory or file.
chezmoi package_add package_name file_or_directory # specify package when add file or package
chezmoi package_search package_name # only search history about that package
chezmoi package_list_directory package_name # list package_name's directory or files

This is an interesting idea (using chezmoi state to be able to track which files belong to which packages), but I’m not sure that it fits within the scope of what chezmoi does.

I don't think that using chezmoi state is the right way to do this (if the state file goes away, chezmoi can reconstruct it by reapplying everything, but this data would be permanently lost). This might be something that could be added for #2673 via something like #2273, because additional attributes could be added.

If we reframe this from package to group, then with such metadata, one could potentially do chezmoi apply --group vim to do a filtered apply only to files within the vim group.

The fundamental problem of splitting things into separate groups is that it assumes that it is possible to split things into separate groups. For example, is the part of your vim configuration for editing .gitignore files part of your vim config, part of your git config, both, or neither?

For this reason, chezmoi has deliberately avoided any kind of grouping.

mjkx5 commented

I know your meaning, although I think .gitignore belonging to current directory package.

chezmoi managed --include=dirs will list all managed dirs, but It is so unintuitive.

.config/Kvantum
.config/Kvantum/Catppuccin-Latte
.config/Kvantum/Catppuccin-Mocha
.config/hypr
.config/hypr/UserConfigs
.config/hypr/UserScripts
.config/hypr/configs
.config/hypr/scripts

In my opinion, It's two package, Kvantum, hypr package. It is intuitive and clear.

In package inner, search directory using directory . eg: Kvantum :

$ chezmoi package_search_dir Kvantum
.config/Kvantum
.config/Kvantum/Catppuccin-Latte
.config/Kvantum/Catppuccin-Mocha

You can tell chezmoi to only consider specific directories, for example:

chezmoi apply ~/.config/Kvantum

will only make changes to ~/.config/Kvantum.

If you want to see the history for this directory, you can use:

chezmoi git -- log $(chezmoi source-path ~/.config/Kvantum)

What other functionality do you need?

mjkx5 commented

@twpayne It's awesome. thanks