uninstall.sh 1.2 KB

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