(install.sh): add backup and restore logic for .gitconfig to prevent loss during installation

This commit is contained in:
Frank Qing
2024-05-01 17:35:18 +08:00
parent 5e1595812c
commit 7b214c6bad

View File

@@ -20,6 +20,13 @@ do
esac
done
if [ -f ~/.gitconfig ]; then
cp ~/.gitconfig ~/.gitconfig.backup
echo "Backup of .gitconfig created."
else
echo ".gitconfig does not exist, no backup created."
fi
if command -v zsh &> /dev/null && command -v git &> /dev/null && command -v wget &> /dev/null && command -v fc-cache &> /dev/null; then
echo -e "ZSH, Git, wget, and fontconfig are already installed\n"
else
@@ -30,6 +37,14 @@ else
fi
fi
if [ -f ~/.gitconfig.backup ]; then
mv ~/.gitconfig.backup ~/.gitconfig
echo "Restored .gitconfig from backup."
else
echo "No .gitconfig backup found to restore."
fi
ZSH="$HOME/.oh-my-zsh"
if mv -n ~/.zshrc ~/.zshrc-backup-$(date +"%Y-%m-%d"); then # backup .zshrc