Last active
March 25, 2018 11:16
-
-
Save conrad784/25be530c86c77a508119b0adef320a52 to your computer and use it in GitHub Desktop.
bootstrap config files
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
#!/bin/sh | |
# found here: https://developer.atlassian.com/blog/2016/02/best-way-to-store-dotfiles-git-bare-repo/ | |
# tried to improve to work with subfolders, but something is wrong, sometimes have to run twice | |
git clone --bare [email protected]:conrad784/dotfiles.git $HOME/.cfg | |
function config { | |
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@ | |
} | |
function mv_fullpath(){ | |
copy_file="$1"; | |
#echo "cf: $copy_file"; | |
to_file="$2"; | |
#echo "tf: $to_file"; | |
to_path="$( dirname ${to_file} )"; | |
#echo "tp: $to_path"; | |
mkdir -p $to_path; | |
#echo "mv: $copy_file $to_path"; | |
mv $copy_file $to_path; | |
#echo "" | |
} | |
mkdir -p .config-backup | |
config checkout | |
if [ $? = 0 ]; then | |
echo "Checked out config."; | |
else | |
echo "Backing up pre-existing dot files."; | |
FILES=$( config checkout 2>&1 | egrep "\s+\." | awk {'print $1'} ) | |
for x in $FILES; | |
do | |
echo "moving $x" | |
mv_fullpath $x .config-backup/$x; | |
done | |
echo "Finished backing up."; | |
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