twpayne / chezmoi

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

Managing machine-to-machine differences #3331

Closed Niko72 closed 12 months ago

Niko72 commented 1 year ago

I would like to use completely different dotfiles on different machines.

As described here I created e.g. following files in the source directory: ~/.local/share/chezmoi/.zshrc_linux ~/.local/share/chezmoi/.zshrc_android ~/.local/share/chezmoi/dot_zshrc.tmpl The last file with the content:

{{- if eq .chezmoi.os "linux" -}}
{{-   include ".zshrc_linux" -}}
{{- else if eq .chezmoi.os "android" -}}
{{-   include ".zshrc_android" -}}
{{- end -}}

But if I want to edit the source file with chezmoi edit ~/.zshrc it opens the dot_zshrc.tmpl file in the source directory and not the expected .zshrc file.

So how is the recommended way to edit the .zshrc source file in this case?

twpayne commented 1 year ago

In this case the recommended way is to open the relevant source file directly in your editor. chezmoi cd can help you get to the correct directory.

It is not possible for chezmoi (or any program, for that matter) to reliably determine when the contents of a template file are in fact the contents of another file.

twpayne commented 12 months ago

Hopefully this is now resolved. Please re-open if necessary.