e8716cb5703e4cff8dd6f0a4ba12ded7aee86f2d

Author
Marc Cornellà <hello@mcornella.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

fix(uninstall): fix renaming .zshrc when no original rc file found

Fixes #9629
Fixes #9700

Diff

 1diff --git a/tools/uninstall.sh b/tools/uninstall.sh
 2index b327a016300a84551c8dbd4d2a89c2ba9de3f427..6a0e7b4c7440d1827c12bd733648a3f457b11542 100644
 3--- a/tools/uninstall.sh
 4+++ b/tools/uninstall.sh
 5@@ -9,20 +9,20 @@ if [ -d ~/.oh-my-zsh ]; then
 6   rm -rf ~/.oh-my-zsh
 7 fi
 8 
 9+if [ -e ~/.zshrc ]; then
10+  ZSHRC_SAVE=~/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S)
11+  echo "Found ~/.zshrc -- Renaming to ${ZSHRC_SAVE}"
12+  mv ~/.zshrc "${ZSHRC_SAVE}"
13+fi
14+
15 echo "Looking for original zsh config..."
16 ZSHRC_ORIG=~/.zshrc.pre-oh-my-zsh
17 if [ -e "$ZSHRC_ORIG" ]; then
18   echo "Found $ZSHRC_ORIG -- Restoring to ~/.zshrc"
19-
20-  if [ -e ~/.zshrc ]; then
21-    ZSHRC_SAVE=~/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S)
22-    echo "Found ~/.zshrc -- Renaming to ${ZSHRC_SAVE}"
23-    mv ~/.zshrc "${ZSHRC_SAVE}"
24-  fi
25-
26   mv "$ZSHRC_ORIG" ~/.zshrc
27-
28   echo "Your original zsh config was restored."
29+else
30+  echo "No original zsh config found"
31 fi
32 
33 if hash chsh >/dev/null 2>&1 && [ -f ~/.shell.pre-oh-my-zsh ]; then