uninstall.sh 969 Bytes
Newer Older
1
read -r -p "Are you sure you want to remove Oh My Zsh? [y/N] " confirmation
LE Manh Cuong's avatar
LE Manh Cuong committed
2
if [ "$confirmation" != y ] && [ "$confirmation" != Y ]; then
3
4
  echo "Uninstall cancelled"
  exit
5
6
fi

Robby Russell's avatar
Robby Russell committed
7
echo "Removing ~/.oh-my-zsh"
LE Manh Cuong's avatar
LE Manh Cuong committed
8
if [ -d ~/.oh-my-zsh ]; then
Robby Russell's avatar
Robby Russell committed
9
10
11
  rm -rf ~/.oh-my-zsh
fi

12
echo "Looking for original zsh config..."
13
14
15
ZSHRC_ORIG=~/.zshrc.pre-oh-my-zsh
if [ -e "$ZSHRC_ORIG" ]; then
  echo "Found $ZSHRC_ORIG -- Restoring to ~/.zshrc"
16

17
18
19
20
  if [ -e ~/.zshrc ]; then
    ZSHRC_SAVE=~/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S)
    echo "Found ~/.zshrc -- Renaming to ${ZSHRC_SAVE}"
    mv ~/.zshrc "${ZSHRC_SAVE}"
21
22
  fi

23
  mv "$ZSHRC_ORIG" ~/.zshrc
24

LE Manh Cuong's avatar
LE Manh Cuong committed
25
  echo "Your original zsh config was restored. Please restart your session."
Robby Russell's avatar
Robby Russell committed
26
else
LE Manh Cuong's avatar
LE Manh Cuong committed
27
  if hash chsh >/dev/null 2>&1; then
28
29
30
31
32
    echo "Switching back to bash"
    chsh -s /bin/bash
  else
    echo "You can edit /etc/passwd to switch your default shell back to bash"
  fi
Robby Russell's avatar
Robby Russell committed
33
34
fi

35
echo "Thanks for trying out Oh My Zsh. It's been uninstalled."