Skip to content

Instantly share code, notes, and snippets.

@crpb
Last active February 13, 2022 07:50
Show Gist options
  • Save crpb/7c71350a4816aa38ec02e6fc6e6dd4ab to your computer and use it in GitHub Desktop.
Save crpb/7c71350a4816aa38ec02e6fc6e6dd4ab to your computer and use it in GitHub Desktop.
Move all your beloved dotfiles to a subdirectory and automagically track changes with git
mkdir -p ~/.dotfiles
cd ~/.dotfiles
git init
cd ~/
find ~/ -maxdepth 1 -regextype posix-extended -regex '.*[.](bash|zsh|profile|Xresources|xinitrc|vimrc|function|alias|sig|tmux|xbind|netrc|nethack|fasd|viminfo|selected_editor|tool-versions).*' -type f,l -exec mv -t ~/.dotfiles/ '{}' \;
find ~/.dotfiles -maxdepth 1 -type f,l -exec ln -s -t ~/ '{}' \;
crontab -l | cat<<EOF |crontab -
*/5 * * * * bash -c "cd ~/.dotfiles && git add . && git commit -m \$(echo \$(date +\%Y\%m\%d\%H\%M))" >> /dev/null
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment