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 combines this with some convenient shell aliases, a couple of functions, and FZF's matching magic to track your dotfiles files with ease.
dotGit has modest aims:
- π‘ keep configuration files where tools expect them in
$HOME - π stay as light and close to git and the shell as possible
- π reduce friction and make configuration changes quick and convenient
Most of dotGit is just some aliases that point to the --git-dir and --work-tree.
The real daily winners for me are the "edit" (.ge) and "grep" (.gg) aliases. They get me to where I need to be fast.
.gl- pull changes from origin- make some changes. Try:
.ge zshrc- presents all files withzshrcin the name.gg PATH- runsgit grepacross your dotfiles and presents the results
.gc -m 'commit comment' .zshrc- will commit the changes.gp- pushes the changes to the origin
| alias | action | note |
|---|---|---|
| .git | git --git-dir=${DOT_REPO} --work-tree=${DOT_HOME} |
|
| .g | .git |
|
| .ga | .git add |
|
| .gc | .git commit |
|
| .gco | .git checkout |
|
| .gd | .git diff |
|
| .ge | calls the _dotgit_ge helper function |
the dotGit edit feature 1 |
| .gg | calls the _dotgit_gg helper function |
grep your dotfiles, and jump to correct line 2 |
| .gss | .git status --short |
|
| .glo | .git log --oneline --decorate |
|
| .glg | .git log --stat |
|
| .glgp | .git log --stat --patch |
|
| .gbl | .git blame -w |
|
| .gb | .git branch |
|
| .gba | .git branch --all |
|
| .gbd | .git branch --delete |
|
| .gbD | .git branch --delete --force |
|
| .gm | .git merge |
|
| .gma | .git merge --abort |
|
| .gmc | .git merge --continue |
|
| .gc! | .git commit --verbose --amend |
|
| .gcm | .git commit --message |
|
| .gcp | .git cherry-pick |
|
| .gcpa | .git cherry-pick --abort |
|
| .gcpc | .git cherry-pick --continue |
|
| .gclean | .git clean --interactive -d |
|
| .ginit | git init --bare "${DOT_REPO}"; .git config --local status.showUntrackedFiles no |
3 |
| .gp | .git push |
requires DOT_ORIGIN be set |
| .gl | .git pull |
requires DOT_ORIGIN be set |
| .gclone | git clone --bare "${DOT_ORIGIN}" "${DOT_REPO}"; .git config --local status.showUntrackedFiles no |
|
| .lazygit | lazygit -g ${DOT_REPO}/ -w ${DOT_HOME} |
requires lazygit be installed |
| .gitui | gitui -d ${DOT_REPO}/ -w ${DOT_HOME} |
requires gitui to be installed |
- clone this repository or simply copy the dotgit.sh
- add some configuration sauce to your shell initialization (.i.e.
.zshrcor.bashrc). TheDOT_REPOandDOT_HOMEvariables must be set for the dotgit.sh to load!
export DOT_REPO="${HOME}/.dotfiles" # this is where the repo will live
export DOT_HOME="${HOME}" # this is generally the same as `$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
Existing configuration 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.
- command line completion
- manage system configuration files
- GNU Stow
- dotbare (this is close in spirit to dotGit, and can be used together with dotGit from what I can tell)
- Home Manager