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
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

25
26
27
28
29
30
31
32
33
34
35
36
  echo "Your original zsh config was restored."
fi

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

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