Parent directory

uninstall.sh

1203 bytes
 1if 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
11fi
12
13read -r -p "Are you sure you want to remove Oh My Zsh? [y/N] " confirmation
14if [ "$confirmation" != y ] && [ "$confirmation" != Y ]; then
15  echo "Uninstall cancelled"
16  exit
17fi
18
19echo "Removing ~/.oh-my-zsh"
20if [ -d ~/.oh-my-zsh ]; then
21  rm -rf ~/.oh-my-zsh
22fi
23
24if [ -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}"
28fi
29
30echo "Looking for original zsh config..."
31ZSHRC_ORIG=~/.zshrc.pre-oh-my-zsh
32if [ -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."
36else
37  echo "No original zsh config found"
38fi
39
40echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
41echo "Don't forget to restart your terminal!"