uninstall.sh 1.17 KB
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
13
14
15
16
17
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}"
fi

18
echo "Looking for original zsh config..."
19
20
21
22
ZSHRC_ORIG=~/.zshrc.pre-oh-my-zsh
if [ -e "$ZSHRC_ORIG" ]; then
  echo "Found $ZSHRC_ORIG -- Restoring to ~/.zshrc"
  mv "$ZSHRC_ORIG" ~/.zshrc
23
  echo "Your original zsh config was restored."
24
25
else
  echo "No original zsh config found"
26
27
fi

28
29
if hash chsh >/dev/null 2>&1 && [ -f ~/.shell.pre-oh-my-zsh ]; then
  old_shell=$(cat ~/.shell.pre-oh-my-zsh)
30
31
32
  echo "Switching your shell back to '$old_shell':"
  if chsh -s "$old_shell"; then
    rm -f ~/.shell.pre-oh-my-zsh
33
  else
34
    echo "Could not change default shell. Change it manually by running chsh"
35
    echo "or editing the /etc/passwd file."
36
  fi
Robby Russell's avatar
Robby Russell committed
37
38
fi

39
echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
40
echo "Don't forget to restart your terminal!"