summaryrefslogtreecommitdiff
path: root/tools/uninstall.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/uninstall.sh')
-rw-r--r--tools/uninstall.sh32
1 files changed, 19 insertions, 13 deletions
diff --git a/tools/uninstall.sh b/tools/uninstall.sh
index bf2244be8..b327a0163 100644
--- a/tools/uninstall.sh
+++ b/tools/uninstall.sh
@@ -10,25 +10,31 @@ if [ -d ~/.oh-my-zsh ]; then
fi
echo "Looking for original zsh config..."
-if [ -f ~/.zshrc.pre-oh-my-zsh ] || [ -h ~/.zshrc.pre-oh-my-zsh ]; then
- echo "Found ~/.zshrc.pre-oh-my-zsh -- Restoring to ~/.zshrc";
+ZSHRC_ORIG=~/.zshrc.pre-oh-my-zsh
+if [ -e "$ZSHRC_ORIG" ]; then
+ echo "Found $ZSHRC_ORIG -- Restoring to ~/.zshrc"
- if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
- ZSHRC_SAVE=".zshrc.omz-uninstalled-$(date +%Y%m%d%H%M%S)";
- echo "Found ~/.zshrc -- Renaming to ~/${ZSHRC_SAVE}";
- mv ~/.zshrc ~/"${ZSHRC_SAVE}";
+ if [ -e ~/.zshrc ]; then
+ ZSHRC_SAVE=~/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S)
+ echo "Found ~/.zshrc -- Renaming to ${ZSHRC_SAVE}"
+ mv ~/.zshrc "${ZSHRC_SAVE}"
fi
- mv ~/.zshrc.pre-oh-my-zsh ~/.zshrc;
+ mv "$ZSHRC_ORIG" ~/.zshrc
- echo "Your original zsh config was restored. Please restart your session."
-else
- if hash chsh >/dev/null 2>&1; then
- echo "Switching back to bash"
- chsh -s /bin/bash
+ echo "Your original zsh config was restored."
+fi
+
+if hash chsh >/dev/null 2>&1 && [ -f ~/.shell.pre-oh-my-zsh ]; then
+ old_shell=$(cat ~/.shell.pre-oh-my-zsh)
+ echo "Switching your shell back to '$old_shell':"
+ if chsh -s "$old_shell"; then
+ rm -f ~/.shell.pre-oh-my-zsh
else
- echo "You can edit /etc/passwd to switch your default shell back to bash"
+ echo "Could not change default shell. Change it manually by running chsh"
+ echo "or editing the /etc/passwd file."
fi
fi
echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
+echo "Don't forget to restart your terminal!"