| 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 | |
| 13 | read -r -p "Are you sure you want to remove Oh My Zsh? [y/N] " confirmation |
| 14 | if [ "$confirmation" != y ] && [ "$confirmation" != Y ]; then |
| 15 | echo "Uninstall cancelled" |
| 16 | exit |
| 17 | fi |
| 18 | |
| 19 | echo "Removing ~/.oh-my-zsh" |
| 20 | if [ -d ~/.oh-my-zsh ]; then |
| 21 | rm -rf ~/.oh-my-zsh |
| 22 | fi |
| 23 | |
| 24 | if [ -e ~/.zshrc ]; then |
| 25 | ZSHRC_SAVE=~/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S) |
| 26 | echo "Found ~/.zshrc -- Renaming to ${ZSHRC_SAVE}" |
| 27 | mv ~/.zshrc "${ZSHRC_SAVE}" |
| 28 | fi |
| 29 | |
| 30 | echo "Looking for original zsh config..." |
| 31 | ZSHRC_ORIG=~/.zshrc.pre-oh-my-zsh |
| 32 | if [ -e "$ZSHRC_ORIG" ]; then |
| 33 | echo "Found $ZSHRC_ORIG -- Restoring to ~/.zshrc" |
| 34 | mv "$ZSHRC_ORIG" ~/.zshrc |
| 35 | echo "Your original zsh config was restored." |
| 36 | else |
| 37 | echo "No original zsh config found" |
| 38 | fi |
| 39 | |
| 40 | echo "Thanks for trying out Oh My Zsh. It's been uninstalled." |
| 41 | echo "Don't forget to restart your terminal!" |