Closed maverick1872 closed 12 months ago
.chezmoiignore
already applies to scripts. You'll need to use the target path of the script (i.e. with all the attributes like run_
and once_
removed).
For an example, see my .chezmoiignore
, which applies to per-OS directories in .chezmoiscripts
.
Sorry; should have included my ignore file as it stood originally.
bootstrap/
## Mac System Ignores
{{- if contains "darwin" .osID }}
.chezmoiscripts/arch/
.chezmoiscripts/debian/
.config/awesome
.config/rofi
.config/X11
{{- end }}
## Global Linux System Ignores
{{- if contains "linux" .osID }}
.config/iterm
{{- end }}
## Arch System Ignores
{{- if contains "arch" .osID }}
.chezmoiscripts/debian/
{{- end }}
## Debian System Ignores
{{- if contains "debian" .osID }}
.chezmoiscripts/arch/
{{- end }}
Played with it some more as per your reply and reference material (thanks by the way)! Looks like I can only get the folder to successfully ignore when I include the **
. As such the following are my results.
Does work:
.chezmoiscripts/mac/**
Does not work:
.chezmoiscripts/mac
.chezmoiscripts/mac/
Given I have a solution I can consider this solved and this can be closed as far as I'm concerned.
@maverick1872 FYI, the first block has too many whitespace control characters:
bootstrap/
## Mac System Ignores.chezmoiscripts/arch/
.chezmoiscripts/debian/
.config/awesome
.config/rofi
.config/X11
## Global Linux System Ignores
## Arch System Ignores
## Debian System Ignores
.chezmoiscripts/arch/
You can pipe the contents of your .chezmoiignore
to execute-template
to verify.
Given that this particular file isn't used outside of chezmoi, I would recommend removing all whitespace control characters to avoid subtle issues like this.
@bradenhilton the only issue with the provided example afaict is the stray right chomping character that was on the "Mac System Ignores". This has been fixed locally, beyond just further tweaks I've made.
Or is there some other issue I'm unaware of?
Ignore template as currently stands which seems to be behaving as desired.
bootstrap/
{{- if contains "darwin" .osID }}
## Mac System Ignores
.chezmoiscripts/arch/**
.chezmoiscripts/debian/**
.config/awesome
.config/rofi
.config/X11
{{- end }}
{{- if contains "linux" .osID }}
## Global Linux System Ignores
.config/iterm
.chezmoiscripts/mac/**
{{- end }}
{{- if contains "arch" .osID }}
## Arch System Ignores
.chezmoiscripts/debian/**
{{- end }}
{{- if contains "debian" .osID }}
## Debian System Ignores
.chezmoiscripts/arch/**
{{- end }}
Closing due to age. Please re-open if needed.
Is your feature request related to a problem? Please describe.
Currently, the only way to control whether a script runs is via a .tmpl or env var conditional within the script. Generally I prefer the former given it prevents it from populating in the diff output on machines it's irrelevant for. Unfortunately this forces me to make every script that's Machine specific a template, when I feel there are simpler alternatives to "ignoring" scripts on specific machines.
Describe the solution you'd like
Adding a script, or directory of scripts to our
.chezmoiignore
would additionally prevent those scripts from executing.