I wonder if there are more convenient ways to do this.
I wonder if there are more convenient ways to do this.
The idea is to make an alias that runs git so that it treats your home directory as a git repository and you can directly commit them.
I would recommend bypassing that article's `config config --local status.showUntrackedFiles no` setting and setting a `~/.gitignore`. This way, git will never tinker with your home directory if you accidentally run the wrong command.
So the complete list of setup commands is:
# Only needs to be done the first time
cat >~/.gitignore<<'EOF'
*
!/.bashrc
!/.zshrc
EOF
# On subsequent runs
git clone --bare ssh://git/cfg.git "${HOME}/.cfg"
function config() {
git --git-dir="${HOME}/.cfg/" --work-tree="${HOME}" "${@}"
}
config checkout -- ~/.gitignore
config reset ~
config checkout -- ~
config submodule update --init --recursive --remote
One caveat is adding files in subdirectories (`~/. config/...`), but just requires changes in your gitignoreWould be great if I could combine with a local secrets engine. Like Hashicorp Vault but local.
This is useful because sometimes you want to use the same configuration file on different systems and they usually need some customizations to adapt to each one, which can be done automatically by ansible based on jinja2 templates.
If I were on a fresh VM with an internet connection and wanted my vimrc, I would do
curl https://dotfilehub.com/knoebber/vimrc >> ~/.vimrcA few are in a git repo, such as my homedir's Makefile: