Everything1 is under version control in GitHub and have done so to be able to install other machines in a reproducible way.
The software I need is typically installed via Homebrew, so it is quite MacOS oriented. Installing from Apple Store could benefit from mas but I haven't tried yet.
I store the instructions to do set my machines up in various files/scripts similarly to what Mathias Bynens did.
I use the detached work tree approach whereby I keep my GIT repo away from my HOME directory.
The following is expecially needed for a dotfiles repo
- setup what to ignore:
$ cd $HOME $ cat <<EOF # specific ignores .DS_Store *.pyc node_modules # do not ignore: !bin/ EOF > $HOME/.gitignore_global
- and add it to the global git config in $HOME
$ git config --global core.excludesfile $HOME/.gitignore_global
I got inspired by this post (no more reacheable) and this is how I did it:
- create your git repo
$ cd $HOME $ mkdir -p $HOME/.dotfiles
- make an alias,
home
, to manage this special repo$ echo "alias home='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'" >> $HOME/.zshrc $ source $HOME/.zshrc
- init the repo and start adding dotfiles
$ home init $ home add $HOME/.bash_profile $HOME/.bashrc $HOME/.bash_aliases $ home commit -m 'Initial commit' $ home remote add origin git@github.com:espinielli/.dotfiles $ home push origin master
Now to use (and contribute) from a different machine
- backup your existing dot files
- clone the repo
$ cd $HOME $ git clone https://github.com/espinielli/dotfiles.git /tmp/dotfiles.git
- move git repo configuration info in
$HOME/.dotfiles/
$ mv /tmp/dotfiles.git/.git $HOME/.dotfiles/
- enable
dotglob
and copy the dot files to$HOME
$ setopt -s dotglob # in bash $ setopt globdots # in zsh $ mv -i /tmp/dotfiles.git/* $HOME
Finally properly configure what to ignore, see the 'ignoring' section above.
Use home ls-files
to list the version controlled dotfiles.
Execute
$HOME/.github/brew.sh
See .zsh-config
.
- Detached work tree approach.
- I got inspired from this, this and this as well.
Footnotes
-
well almost, I am not yet decided on how to manage secrets...separate private repo? Then what about framework data/privacy leaks? What about personal mistakes? ↩