Skip to content

Create the same file differently, depending on a condition? #2277

Answered by twpayne
FranklinYu asked this question in Q&A
Discussion options

You must be logged in to vote

Currently, there is no way for the same path (~/.cache) to have different types on different machines. However, there is a work-around for this specific case.

~/.cache is a directory on Linux by default, so you can ignore it on Linux, and then make it a symlink on macOS. For example (not tested):

In your .chezmoiignore:

{{ if ne .chezmoi.os "darwin" }}
.cache
{{ end }}

in ~/.local/share/chezmoi/symlink_dot_cache:

Library/Caches

This will make ~/.cache a symlink to ~/Library/Caches on macOS and ignore ~/.cache on all other OSes.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@FranklinYu
Comment options

@twpayne
Comment options

@FranklinYu
Comment options

@twpayne
Comment options

Answer selected by twpayne
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants