Closed richukuttan closed 2 years ago
It's not necessary to escape the space with \
. Try:
.config/Bitwarden CLI
.config/Bitwarden CLI/**
to ignore the .config/Bitwarden CLI
directory and everything in it.
That doesn't work either. Unlike the output of 721, I do not see any warning about files being skipped either.
Since I'm just starting to create my dotfiles, I'm trying to get this right by removing the local chezmoi folder and reinitializing it. This is what I'm doing to check:
`
rm -rf ~/.local/share/chezmoi chezmoi init echo ".config/Bitwarden CLI/" > $(chezmoi source-path)/.chezmoiignore echo ".config/Bitwarden CLI/**" >> $(chezmoi source-path)/.chezmoiignore cat $(chezmoi source-path)/.chezmoiignore .config/Bitwarden CLI/ .config/Bitwarden CLI/** chezmoi add .config ls private_dot_config/private_Bitwarden\ CLI/ | wc -l 1 `
This gives me one file in the folder. Is there some other config that saves the previous state of the bitwarden file and rewrites it when it doesn't see it? Or a better way to clean chezmoi?
(Please note that I don't actually type in the $ signs above, since I'm using fish. I just added them in to make the syntax more readable)
Thanks for testing, I'll try to reproduce the problem locally.
This gives me one file in the folder. Is there some other config that saves the previous state of the bitwarden file and rewrites it when it doesn't see it? Or a better way to clean chezmoi?
Yes. You can use create_
files for this. They're not well documented but they do work. If you add a file called create_dot_file
with some contents in your source directory then chezmoi will create a file called .file
in the target directory with those contents if .file
doesn't already exist, or leave .file
untouched if it already exists.
I had a similar question. I'm trying to prevent chezmoi add ~/.config/nvim
from including ~/.config/nvim/plugin/packer_compiled.lua
. I tried adding .config/nvim/plugin/packer_compiled.lua
to my .chezmoiignore
(located at ~/.local/share/chezmoi/.chezmoiignore
), and various other patterns using **/
globbing, however, none prevented chezmoi add
from adding the file into the source directory.
I tried a simpler case of putting foo
in the .chezmoiignore
and adding a foo
file to my home directory. chezmoi add foo
still added foo
to the source directory, with no warning or complaints.
I understand from #721 that .chezmoiignore
was initially implemented for chezmoi apply
, however, a mechanism to prevent chezmoi add
from adding files to the source directory would be most welcome. Controlling the chezmoi add
behavior is what I initially expected. That would be analogous to .gitignore
patterns preventing Git from adding changes from the working directory to the index. The actual behavior right now is more like the converse of .gitignore
: it would be like if .gitignore
prevented Git from overwriting the working directory contents with contents of the index.
I need the existing behavior of .chezmoiignore
, for example, to prevent chezmoi from copying my dotfiles repository's README.md
into my home directory. I could also use a way to stop chezmoi add
from adding certain files or directories from my home directory into the repository.
I have the same feeling of @gotgenes. I want to add a directory, ~/.task/
and all the content, except some, well known, standards, like file *.data and the .git directory. My idea was Chezmoi used .chezmoiignore the same way as .gitignore, to avoid add the files to the repository.
I could also use a way to stop chezmoi add from adding certain files or directories from my home directory into the repository.
This is something I'm sorely missing as well. I have a nodejs project living in its own directory in my dotfiles (for generating a certain kind of repetitive config) and right now I can't figure out a way to chezmoi add ~/.dotfiles
without also copying node_modules
taking several minutes in the process. Other than manually add
ing each and every file in .dotfiles
, sidestepping node_modules
, I opted to go for a full chezmoi add ~/.dotfiles
, wait it out, create a .gitignore
in the source directory, add/commit the files, then do a git clean -fX
to get rid of the files that should have been ignored in the first place. Hopefully you only have to do this kind of thing once or twice so it's not all that bad, but it took me a lot of fiddling around with .chezmoiignore
before realizing it was meant for something completely different and finding this issue.
chezmoi add
will not add files that are ignored by .chezmoiignore
. There's a test for this. If you have observed different behavior, please give details.
Please forgive any oversight as I'm new to chezmoi. My confusion partly stems from the fact I couldn't get it to work excluding directories. Here's an example:
.nkgm/dir/subdir/ # as suggested in docs/reference/#chezmoiignore examples
# or
**/subdir
$ tree .nkgm/dir
/Users/nkgm/.nkgm/dir
└── subdir
└── file
$ chezmoi add ~/.nkgm/dir
chezmoi: /Users/nkgm/.nkgm/dir/subdir/file: parent directory not in source state
The problem goes away for:
**/subdir
**/subdir/*
... which feels counterintuitive. We should clarify if this is intended behavior, and amend the docs accordingly.
Edit:
To exclude node_modules
and avoid the parent directory not in source state error
I actually have to use:
**/node_modules
**/node_modules/**/*
which I guess should come as no surprise as the nesting is several levels deep. Even though it does the right thing in the end, it does feel like chezmoi is doing some unnecessary processing traversing the excluded directories introducing a long delay in the process.
What exactly are you trying to do?
Ignore the bitwarden config file (~/.config/Bitwarden\ CLI/*)
What have you tried so far?
Attempt 1: Add ".config/Bitwarden\ CLI/*" to $(chezmoi source-path)/.chezmoiignore Attempt 2: Add ".config/Bitwarden\ CLI/**" to $(chezmoi source-path)/.chezmoiignore Attempt 3: Add ".config/Bitwarden\ CLI/**/*" to $(chezmoi source-path)/.chezmoiignore Attempt 4: Add ".config/Bitwarden\ CLI/**/*" to $(chezmoi source-path)/.chezmoiignore Attempt 4: Add ".config/**" to $(chezmoi source-path)/.chezmoiignore Attempt 5: Add "private_dot_config/private_Bitwarden\ CLI/*" to $(chezmoi source-path)/.chezmoiignore Attempt 6: Add private_dot_config/private_Bitwarden\ CLI/**" to $(chezmoi source-path)/.chezmoiignore Attempt 7: Add private_dot_config/private_Bitwarden\ CLI/**/*" to $(chezmoi source-path)/.chezmoiignore
Where else have you checked for solutions?
Output of any commands you've tried with
--verbose
Output of
chezmoi doctor