Skip to content

Is it possible to use a template in a run_once* file name? #3775

Answered by Lockszmith-GH
0xjams asked this question in Q&A
Discussion options

You must be logged in to vote

Did a quick search for chezmoiignore and chezmoiscripts and found #2510

I then tested it like this in PowerShell:

> Set-Location "$(chezmoi source-path)"
### Create the two flavors of run_once_script that will alternate based on os
> mkdir .chezmoiscripts
> '"Hello World! PS1"' > .chezmoiscripts/run_once_script.ps1
> '#!/bin/bash'+"`n"+'echo "Hello World! sh"' > .chezmoiscripts/run_once_script.sh
### test it out - what's managed, what's ignored
> chezmoi ignored

> chezmoi managed
.chezmoiscripts/script.ps1
.chezmoiscripts/script.sh

### add template pattern to .chezmoiignore
> '.chezmoiscripts/script{{ if eq .chezmoi.os "windows" }}.sh{{ else }}.ps1{{ end }}' >> .chezmoiignore
### Test t…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by 0xjams
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants