Skip to content

Instantly share code, notes, and snippets.

@nicoelayda
Created March 9, 2024 22:25
Show Gist options
  • Select an option

  • Save nicoelayda/55bcf188ef3f95c696f4054b696c8975 to your computer and use it in GitHub Desktop.

Select an option

Save nicoelayda/55bcf188ef3f95c696f4054b696c8975 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
git clone --bare https://github.com/nicoelayda/dotfiles.git $HOME/.dotfiles
function dotfiles {
git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME $@
}
mkdir -p .dotfiles-backup
dotfiles checkout
if [ $? = 0 ]; then
echo "Checked out dotfiles.";
else
echo "Backing up pre-existing dotfiles.";
files=$(dotfiles checkout 2>&1 | egrep "\t+" | awk {'print $1'})
for f in $files;
do
dir_name=$(dirname "$f")
file_name=$(basename "$f")
mkdir -p .dotfiles-backup/$dir_name
mv $f .dotfiles-backup/$dir_name/$file_name
done;
dotfiles checkout
fi;
dotfiles config status.showUntrackedFiles no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment