From 7b214c6badb2f2dcd3bca73cb2fe4d06f642081d Mon Sep 17 00:00:00 2001 From: Frank Qing Date: Wed, 1 May 2024 17:35:18 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20(install.sh):=20add=20backup=20and?= =?UTF-8?q?=20restore=20logic=20for=20.gitconfig=20to=20prevent=20loss=20d?= =?UTF-8?q?uring=20installation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/install.sh b/install.sh index 4a198cf..fc92729 100755 --- a/install.sh +++ b/install.sh @@ -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