Skip to content

Instantly share code, notes, and snippets.

@jimray
Last active September 20, 2023 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimray/dad38720ddcfbca58e8f5a1ac1af00d7 to your computer and use it in GitHub Desktop.
Save jimray/dad38720ddcfbca58e8f5a1ac1af00d7 to your computer and use it in GitHub Desktop.
Set up a dotfiles-style bare git repo. Install: curl -Lks https://gist.githubusercontent.com/jimray/dad38720ddcfbca58e8f5a1ac1af00d7/raw | /bin/bash
# originally here: https://developer.atlassian.com/blog/2016/02/best-way-to-store-dotfiles-git-bare-repo/
#
# install:
# curl -Lks https://gist.githubusercontent.com/jimray/dad38720ddcfbca58e8f5a1ac1af00d7/raw | /bin/bash
git clone --bare https://github.com/jimray/config.git $HOME/.cfg
function config {
local git_path
git_path=$(which git) # Get the path to the user's installed Git
if [ -n "$git_path" ]; then
$git_path --git-dir=$HOME/.cfg/ --work-tree=$HOME "$@"
else
echo "Git is not installed or not found in your PATH."
fi
}
mkdir -p .config-backup
config checkout
if [ $? = 0 ]; then
echo "Checked out config.";
else
echo "Backing up pre-existing dot files.";
config checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} mv {} .config-backup/{}
fi;
config checkout
config config status.showUntrackedFiles no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment