3.8 KiB
dotGit - 🐚 shell aliases + 🪄 dotfiles + 🧸 bare git repo
There are a lot of ways to manage your dotfiles. dotGit implements an idea that has been floating around on the internet for a while: a bare git repo for storing your dotfiles. A quick search finds this post, but there may be older sources.
dotGit has modest aims:
- 🏡 keep config files where tools expect them in
$HOME - 🐚 stay as light and close to git and the shell as possible
- 🚀 reduce friction and make config changes quick and convenient
dotGit gives you a handful of shell aliases (tested with zsh🐚 and bash) to make dotfile management quick and easy. The shortcuts mimic a subset of those found in the oh-my-zsh git plugin.
.gis the alias for runninggitwith correct--git-dirand--work-tree.garunsgit add.gcrunsgit commmit.gcorunsgit checkout.gdrunsgit diff.gssshows thegit status --short.gpwillgit pushthe changes to the origin.glwillgit pullchanges from the origin.glorunsgit log --oneline --decorate.glgrunsgit log --stat.glgprunsgit log --stat --patch.ggrunsgit grepon your dotfiles. If FZF is installed it will be used to present the matches, and make it easy open your$EDITORon the right line (works with vi, emacs, nano, micro, and any editor that accepts the+<number>syntax to indicate the line number)..ge(requires FZF) lists all files using FZF and opens the selected file in your$EDITOR.lazygit(requires lazygit) will runlazygitwith the correct-gand-w.gitui(requires gitui) will rungituiwith the correct-dand-w
There are two additional aliases used to (re)set up the bare git setup.
.ginitcreates the bare git repository in$DOT_FILESdirectory..gclonewill clone the repository set in$DOT_ORIGINinto the$DOT_FILESdirectory
requirements
installation
- clone this repository or simply copy the dotGit.sh
- add some config sauce to your shell initialization (.i.e.
.zshrcor.bashrc). TheDOT_FILESandDOT_HOMEvariables must be set for the dotGit.sh to load!
export DOT_FILES="${HOME}/.dotfiles"
export DOT_HOME="${HOME}"
export DOT_ORIGIN="git@github.com:user/your-dotfiles-repo.git" # optional
source <path to dotGit.sh>`
- restart your shell or
source ~/.zshrcorsource ~/.bashrc - run
.ginitor.gclone(see the initial clone setup below, if cloning) .gc <branch>to checkout the config files
initial clone cleanup
Existing config files will prevent checking out the files. To list the files causing the checkout to fail, run the following.
.g checkout 2>&1|grep -E '^\s'|cut -f2-|xargs -I {} echo "{}"
To remove all the conflicting files, simply change the echo in the above command to rm. This will delete files, so be sure you want to remove them. Once the files are removed the checkout will succeed.
alternatives
- GNU Stow
- dotbare (this is close in spirit to dotGit, and can be used together with dotGit from what I can tell)
- Home Manager