Expand description
Drop-in style installation.
Some users (or their dotfiles managers — chezmoi, yadm, stow, oh-my-zsh
custom/, etc.) keep their shell config split into a small main file plus
a directory of numbered fragments that the main file sources in lexical
order (e.g. ~/.zshenv.d/00-homebrew.zsh, 10-fnm.zsh, …).
When that convention is in use, appending an inline fenced block to the
main rc file creates drift between the main file and the dotfiles source
of truth. The drop-in install mode writes the same hook content into a
single fragment file in the .d/ directory instead, leaving the main rc
file untouched.
Detection is conservative: we require both that the .d/ directory
exists AND that the main rc file references it from a non-comment line.
That avoids treating an unused empty directory as opt-in.
Functions§
- detect
- Detect whether the user’s rc file in
homereferences the named drop-in directory and that directory exists. Returns the resolved directory path on success. - rc_
references_ dropin - True if any non-comment line in
rc_contentsmentionsdropin_dir_name. - remove
- Remove
<dir>/<filename>if it exists. No-op otherwise. - write
- Write
contentto<dir>/<filename>, creatingdirif needed.