Closed rioka closed 1 year ago
A few things are happening here.
My understanding is that the files are at C:/Users/********/.local/share/chezmoi/dot_bashrc_{linux,windows}
.
https://www.chezmoi.io/reference/templates/functions/include/
Relative paths are interpreted relative to the source directory.
Replacing .bashrc_windows
with dot_bashrc_windows
in the include
will correctly include the contents, but this brings its own issue as you have discovered.
Instead, consider one of the following approaches:
linux
and windows
contents directly in dot_bashrc.tmpl
, using conditionals as needed.dot_bashrc_{linux,windows}
to .chezmoitemplates/bashrc/{linux,windows}
(.chezmoitemplates
doc) and change {{ include ".bashrc_{linux,windows}" }}
to {{ template "bashrc/{linux,windows}" }}
in dot_bashrc.tmpl
.@bradenhilton thanks mate, it works. 🎆
I think the snippet at https://www.chezmoi.io/user-guide/manage-machine-to-machine-differences/#without-using-symlinks should be updated then, because as it is now, unless I'm missing something, it does not work.
Anyway, I'm glad I can proceed with my experiments... really like this tool
I think the snippet at https://www.chezmoi.io/user-guide/manage-machine-to-machine-differences/#without-using-symlinks should be updated then, because as it is now, unless I'm missing something, it does not work.
What exactly does not work? Note that the subsection you link to is written assuming that you've read the section that it is part of.
@twpayne
So I guess I'm missing something... what I was trying to do is based on section "Use completely different dotfiles on different machines", simply (or at least this is what it looks to me) replacing "darwin" with "windows"; so I created files dot_bashrc_windows
and dot_bashrc_linux
, but I did not want to use symlinks... few lines below, I read this statement
The same thing can be achieved using the include function
And there's the snippet which did not work...
The changes suggested here fixed my problem (and I'm more that happy with them) but I still can't figure out what I did wrong the first time, or what part I missed from the linked page.
It's just curiosity: when something does not work as expected (or I cannot make it work) I just want to find out what I did wrong.
I totally agree I am likely missing something trivial, just want to figure out what it is.
🙇
What exactly are you trying to do?
Just started playing with chezmoi after reading a few blogs, and wanted to understand how it works when used with multiple PCs with different OSes; one feature that caught my eye is the possiblity to use templates, so I tried use them to manage
.bashrc
.What have you tried so far?
Working on a Windows 10 machine, I installed chezmoi (using scoop), run
chezmoi init
, then added.bashrc
as a template; so far, so good.Then, I created
dot_bashrc_linux
anddot_bashrc_windows
dot_bashrc_linux
contains just comments for nowdot_bashrc_windows
contains original from my.bashrc
dot_bashrc.tmpl
now contains.chezmoiignore
has been updated as followsWhen I run
chezmoi diff
I get this errorIf I replace
{{ include ".bashrc_windows" }}
with{{ include "dot_bashrc_windows" }}
, I do not get the error any more, but apparently it is detecting.bashrc_windows
as a new file to add to my home directory (and it's eventually added if I runchezmoi apply
, unless I add--interactive
and decide to skip it)Where else have you checked for solutions?
Output of any commands you've tried with
--verbose
flagOutput of
chezmoi doctor