Created
March 9, 2024 22:25
-
-
Save nicoelayda/55bcf188ef3f95c696f4054b696c8975 to your computer and use it in GitHub Desktop.
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
| #!/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