Uninstall restores now the original shell

This commit is contained in:
Antonio QUINTAVALLE 2018-02-06 10:30:33 -05:00
parent 37c2d0ddd7
commit 74f100f62e
2 changed files with 16 additions and 8 deletions

View File

@ -86,6 +86,8 @@ main() {
# If this platform provides a "chsh" command (not Cygwin), do it, man!
if hash chsh >/dev/null 2>&1; then
printf "${BLUE}Time to change your default shell to zsh!${NORMAL}\n"
# Store current shell
grep $USER /etc/passwd | awk -F ":" '{print $7}' >> ~/.shell.pre-oh-my-zsh
chsh -s $(grep /zsh$ /etc/shells | tail -1)
# Else, suggest the user do so manually.
else

View File

@ -9,6 +9,7 @@ if [ -d ~/.oh-my-zsh ]; then
rm -rf ~/.oh-my-zsh
fi
# if we had zsh previously
echo "Looking for original zsh config..."
if [ -f ~/.zshrc.pre-oh-my-zsh ] || [ -h ~/.zshrc.pre-oh-my-zsh ]; then
echo "Found ~/.zshrc.pre-oh-my-zsh -- Restoring to ~/.zshrc";
@ -20,15 +21,20 @@ if [ -f ~/.zshrc.pre-oh-my-zsh ] || [ -h ~/.zshrc.pre-oh-my-zsh ]; then
fi
mv ~/.zshrc.pre-oh-my-zsh ~/.zshrc;
echo "Your original zsh config was restored. Please restart your session."
else
if hash chsh >/dev/null 2>&1; then
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
fi
echo "Restoring default shell..."
if [ -f ~/.shell.pre-oh-my-zsh ] ; then
if hash chsh >/dev/null 2>&1; then
echo "Found ~/.shell.pre-oh-my-zsh -- Restoring your default shell to" $(cat ~/.shell.pre-oh-my-zsh)
chsh -s $(cat ~/.shell.pre-oh-my-zsh)
rm ~/.shell.pre-oh-my-zsh
else
echo "Switching back to bash"
chsh -s /bin/bash
fi
else
echo "You can edit /etc/passwd to switch your default shell back to bash"
fi
echo "Thanks for trying out Oh My Zsh. It's been uninstalled."