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

Add option for "chezmoi managed" to display the matching source or target path. #4054

Open
andre-kotake opened this issue Nov 3, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@andre-kotake
Copy link

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

Currently, chezmoi managed lists all managed files. You can change the output with --path-style to show the absolute/relative target OR source path only for the files. There is no way to visualize both target and source paths together.

I think it would be interesting if there was an option to show both the target AND source paths in a single line for each managed file, as it would provide a quicker way to visualize all files and attributes in one go (ha), plus it would greatly help parsing the results in custom scripts that call chezmoi commands.

Describe the solution you'd like

Since there is already a --tree flag that changes the output formatting, another flag like --full to change the display to show both target and source paths could work, with the paths separated by a ":".

Examples:

$ chezmoi managed --full
.bashrc:private_dot_bashrc
.gitconfig:encrypted_private_dot_gitconfig
$ chezmoi managed --full --path-style source-absolute
/home/.local/share/chezmoi/private_dot_bashrc:/home/user/.bashrc
/home/.local/share/chezmoi/encrypted_private_dot_gitconfig:/home/user/.gitconfig
$ chezmoi managed --full --path-style target-absolute
/home/user/.bashrc:/home/.local/share/chezmoi/private_dot_bashrc
/home/user/.gitconfig:/home/.local/share/chezmoi/encrypted_private_dot_gitconfig

Describe alternatives you've considered

For now, I am running source-path or target-path to get the corresponding entry for each file listed by the managed command or ls on source directory when I want to visualize attributes, however this increases the execution and adds more complexity to handle each file.

Additional context

Thought about this when writing a telescope extension for my nvim-chezmoi plugin. I wanted to list all source managed files but display the target path for each one to the user. Since I need the original source path, I can't just run chezmoi managed --path-style target-absolute. The alternative I am using works fine but makes the file picker lag a bit before displaying so currently I switched this to a file name manual parsing approach, but it would be nice if chezmoi managed itself could handle that.

@andre-kotake andre-kotake added the enhancement New feature or request label Nov 3, 2024
@halostatue
Copy link
Collaborator

I wonder if having something like a --json flag for a use case like this might be better.

@andre-kotake
Copy link
Author

I wonder if having something like a --json flag for a use case like this might be better.

Could work too, but I believe it would be more appropriate to implement a --format parameter, e.g. --format json if that is the the case. My suggestion was because from what I understood from source for managed, it seemed easier to just concatate the two paths.

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

No branches or pull requests

2 participants