Skip to content

dotGit - 🐚 shell aliases + πŸͺ„ dotfiles + 🧸 bare git repo

License

Notifications You must be signed in to change notification settings

opennomad/dotGit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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.

  • .g is the alias for running git with correct --git-dir and --work-tree
  • .ga runs git add
  • .gc runs git commmit
  • .gco runs git checkout
  • .gd runs git diff
  • .gss shows the git status --short
  • .gp will git push the changes to the origin
  • .gl will git pull changes from the origin
  • .glo runs git log --oneline --decorate
  • .glg runs git log --stat
  • .glgp runs git log --stat --patch
  • .gg runs git grep on your dotfiles. If FZF is installed it will be used to present the matches, and make it easy open your $EDITOR on 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 run lazygit with the correct -g and -w
  • .gitui (requires gitui) will run gitui with the correct -d and -w

There are two additional aliases used to (re)set up the bare git setup.

  • .ginit creates the bare git repository in $DOT_FILES directory.
  • .gclone will clone the repository set in $DOT_ORIGIN into the $DOT_FILES directory Both of these aliases also set git's status.showUntrackedFiles to no. This prevents every file in $DOT_HOME from showing as "untracked" by git.

requirements

installation

  1. clone this repository or simply copy the dotgit.sh
  2. add some config sauce to your shell initialization (.i.e. .zshrc or .bashrc). The DOT_FILES and DOT_HOME variables must be set for the dotGit.sh to load!
export DOT_FILES="${HOME}/.dotfiles"
export DOT_HOME="${HOME}"
export DOT_ORIGIN="[email protected]:user/your-dotfiles-repo.git" # optional
source <path to dotgit.sh>`
  1. restart your shell or source ~/.zshrc or source ~/.bashrc
  2. run .ginit or .gclone (see the initial clone setup below, if cloning)
  3. .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

About

dotGit - 🐚 shell aliases + πŸͺ„ dotfiles + 🧸 bare git repo

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages