Search code examples
dotfiles

Chezmoi: ignore files and subdirectories


I've been trying to add Neovim configuration:

~ $ ls .config/nvim
autoload  custom.vim  init.vim  plugged  yankring_history_v2.txt

Working directories autoload/, plugged/, and file yankring_history_v2.txt are not welcome in ~/.local/share/chezmoi repository, naturally.

I tried to put .chezmoiignore into ~/.config/nvim in the hope that

~ $ chezmoi add .conf/nvim

will skip copying the working directories into ~/.local/share/chezmoi repository. This is not the case, unfortunately.

~/.config/nvim/.chezmoiignore:

autoload/
plugged/
yankring_history*.txt

~ $ chezmoi add .conf/nvim;

~ ᐅ ls .local/share/chezmoi/dot_config/nvim
autoload  custom.vim  dot_chezmoiignore  init.vim  plugged  yankring_history_v2.txt

Of course, I can make .gitignore in the chezmoi repository, but I don't think that would be the right way to go.

What is the right way in my case? My purpose is clear, I hope.


Solution

  • .chezmoiignore lives in the repository (and controls $ chezmoi add): ~/.local/share/chezmoi/.chezmoiignore:

    README.*
    
    # Neovim
    **/autoload/
    **/autoload/**/*
    **/plugged/
    **/plugged/**/*
    **/yankring_history*.txt
    

    Discussion