Open denilsonsa opened 9 months ago
Nice suggestion! I'm currently doing this with my shared git config:
- shell:
- description: "Copy shared/git/gitconfig.ini to ~/.gitconfig (if needed)"
command: >
if [ ! -e ~/.gitconfig ]; then
cp shared/git/gitconfig.ini ~/.gitconfig;
fi
quiet: true
A copy
directive might be just the ticket in this situation.
The problem
With the current capabilities of dotbot, I can have a
~/.vim/vimrc
file in my dotfiles, and dotbot will correctly create the link. Inside that file, I am sourcing another file~/.vimrc/vimrc-local
, which should contain local changes that should not be stored in the dotfiles. So far, so good.However, the tricky part is initializing the
-local
file. It should have a certain structure, it should declare a few functions. In other words, there is some boilerplate it should have.The proposed solution
I am proposing a new directive:
skel
(orinitialize
orseed
orcopy
orcopy_without_overwriting
or… well, naming is hard!)It would be declared in a similar way to the
link
directive, but instead of creating a symlink, it would just copy the file over there. Look:On a fresh machine, the outcome would be:
~/.vim/vimrc
→~/dotfiles/base/.vim/vimrc
(symlink)~/.vim/vimrc-local
(regular file, copied from~/dotfiles/base/.vim/vimrc
)On subsequent runs on the same machine:
~/.vim/vimrc
→~/dotfiles/base/.vim/vimrc
(the tool ensures the symlink is still correct)~/.vim/vimrc-local
~/dotfiles/base/.vim/vimrc
The proposed behavior reminds me of
/etc/skel/
.Additional configuration
Maybe the name should be
copy
, and it should have the same configuration keys aslink
:path
create
parent directories as needed.not relevant.relink
force
overwrites the existing file. Dangerous, should be off by default, but maybe useful in some exotic configuration. (e.g. A separate YAML config could be used to "reset" a certain application configuration to a known state.)canonicalize
,if
,ignore-missing
glob
,exclude
,prefix
Alternatives
-local
file in my dotfiles, and I have to remember to copy/create it manually.-local
file in my dotfiles, and I add some customshell
directive to copy only if it doesn't exist.-local
, one for each machine. Many people do that, but it is not desirable for files that contain sensitive information (such as API keys or tokens).Compared to the alternatives, the
skel
/copy
solution has the following advantages:link
.link
.