uninstall.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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; then
  23. if [ -f ~/.shell.pre-oh-my-zsh ]; then
  24. old_shell=$(cat ~/.shell.pre-oh-my-zsh)
  25. else
  26. old_shell=/bin/bash
  27. fi
  28. echo "Switching your shell back to '$old_shell':"
  29. if chsh -s "$old_shell"; then
  30. rm -f ~/.shell.pre-oh-my-zsh
  31. else
  32. echo "Could not change default shell. Change it manually by running chsh"
  33. echo "or editing the /etc/passwd file."
  34. fi
  35. fi
  36. echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
  37. echo "Don't forget to restart your terminal!"