Last active
September 20, 2023 18:32
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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