twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
12.83k stars 477 forks source link

Customize the path for a single file #3905

Open zkkv opened 3 weeks ago

zkkv commented 3 weeks ago

What exactly are you trying to do?

I want to add a settings.json file generated by VS Code to Chezmoi but it's stored under User/profiles/[id]/settings.json. This means that if I add it to Chezmoi, it will have the same relative structure. I want the file in Git to be simply stored under chezmoi/VSCode/settings.json.

What have you tried so far?

If I change the path manually after adding the file, Chezmoi will think the actual file is not tracked anymore. I need to preserve the original file path but also have a consistent associations between the two files.

Where else have you checked for solutions?

twpayne commented 3 weeks ago

See https://www.chezmoi.io/user-guide/manage-machine-to-machine-differences/#handle-different-file-locations-on-different-systems-with-the-same-contents.

zkkv commented 3 weeks ago

Then create files for each system, for example Library/Application Support/App/file.conf.tmpl for macOS and dot_config/app/file.conf.tmpl for Linux.

Wouldn't that preserve the original file structure in version control, the very thing I'm trying to avoid?

twpayne commented 3 weeks ago

In that case use a script to install settings.json to the machine-specific location.