uninstall.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. read -r -p "Are you sure you want to remove Oh My Zsh? [y/N] " confirmation
  2. if [ "$confirmation" != y ] && [ "$confirmation" != Y ]; then
  3. echo "Uninstall cancelled"
  4. exit
  5. fi
  6. echo "Removing ~/.oh-my-zsh"
  7. if [ -d ~/.oh-my-zsh ]; then
  8. rm -rf ~/.oh-my-zsh
  9. fi
  10. echo "Looking for original zsh config..."
  11. ZSHRC_ORIG=~/.zshrc.pre-oh-my-zsh
  12. if [ -e "$ZSHRC_ORIG" ]; then
  13. echo "Found $ZSHRC_ORIG -- Restoring to ~/.zshrc"
  14. if [ -e ~/.zshrc ]; then
  15. ZSHRC_SAVE=~/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S)
  16. echo "Found ~/.zshrc -- Renaming to ${ZSHRC_SAVE}"
  17. mv ~/.zshrc "${ZSHRC_SAVE}"
  18. fi
  19. mv "$ZSHRC_ORIG" ~/.zshrc
  20. echo "Your original zsh config was restored."
  21. fi
  22. if hash chsh >/dev/null 2>&1 && [ -f ~/.shell.pre-oh-my-zsh ]; then
  23. old_shell=$(cat ~/.shell.pre-oh-my-zsh)
  24. echo "Switching your shell back to '$old_shell':"
  25. if chsh -s "$old_shell"; then
  26. rm -f ~/.shell.pre-oh-my-zsh
  27. else
  28. echo "Could not change default shell. Change it manually by running chsh"
  29. echo "or editing the /etc/passwd file."
  30. fi
  31. fi
  32. echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
  33. echo "Don't forget to restart your terminal!"