uninstall.sh 1.2 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. if [ -e ~/.zshrc ]; then
  11. ZSHRC_SAVE=~/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S)
  12. echo "Found ~/.zshrc -- Renaming to ${ZSHRC_SAVE}"
  13. mv ~/.zshrc "${ZSHRC_SAVE}"
  14. fi
  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. mv "$ZSHRC_ORIG" ~/.zshrc
  20. echo "Your original zsh config was restored."
  21. else
  22. echo "No original zsh config found"
  23. fi
  24. if hash chsh >/dev/null 2>&1 && [ -f ~/.shell.pre-oh-my-zsh ]; then
  25. old_shell=$(cat ~/.shell.pre-oh-my-zsh)
  26. echo "Switching your shell back to '$old_shell':"
  27. if chsh -s "$old_shell"; then
  28. rm -f ~/.shell.pre-oh-my-zsh
  29. else
  30. echo "Could not change default shell. Change it manually by running chsh"
  31. echo "or editing the /etc/passwd file."
  32. fi
  33. fi
  34. echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
  35. echo "Don't forget to restart your terminal!"