This commit is contained in:
Tony Xue 2015-10-20 18:08:28 +00:00
commit 64e42f01fb

View file

@ -25,11 +25,11 @@ fi
set -e set -e
CHECK_ZSH_INSTALLED=$(grep /zsh$ /etc/shells | wc -l) CHECK_ZSH_INSTALLED=$(grep /zsh$ /etc/shells | wc -l)
if [ ! $CHECK_ZSH_INSTALLED -ge 1 ]; then CHECK_ZSH_INSTALLED_NON_GLOBALLY=$(which zsh >/dev/null 2>&1; echo $?)
if [ ! "$CHECK_ZSH_INSTALLED" -ge 1 ] && [ ! "$CHECK_ZSH_INSTALLED_NON_GLOBALLY" -eq 0 ]; then
printf "${YELLOW}Zsh is not installed!${NORMAL} Please install zsh first!\n" printf "${YELLOW}Zsh is not installed!${NORMAL} Please install zsh first!\n"
exit exit
fi fi
unset CHECK_ZSH_INSTALLED
if [ ! -n "$ZSH" ]; then if [ ! -n "$ZSH" ]; then
ZSH=~/.oh-my-zsh ZSH=~/.oh-my-zsh
@ -89,10 +89,15 @@ mv -f ~/.zshrc-omztemp ~/.zshrc
# If this user's login shell is not already "zsh", attempt to switch. # If this user's login shell is not already "zsh", attempt to switch.
TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)') TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
# If this platform provides a "chsh" command (not Cygwin), do it, man! # If this platform provides a "chsh" command (not Cygwin) and ZSH is installed
if hash chsh >/dev/null 2>&1; then # globally, do it, man!
if hash chsh >/dev/null 2>&1 && [ "$CHECK_ZSH_INSTALLED" -ge 1 ]; then
printf "${BLUE}Time to change your default shell to zsh!${NORMAL}\n" printf "${BLUE}Time to change your default shell to zsh!${NORMAL}\n"
chsh -s $(grep /zsh$ /etc/shells | tail -1) chsh -s $(grep /zsh$ /etc/shells | tail -1)
# If ZSH only installed non-globally.
elif [ "$CHECK_ZSH_INSTALLED_NON_GLOBALLY" -eq 0 ] && [ ! "$CHECK_ZSH_INSTALLED" -ge 1 ]; then
printf "I can't change your shell automatically.\n"
printf "${BLUE}You need to start ZSH in your preferred way every time!${NORMAL}\n"
# Else, suggest the user do so manually. # Else, suggest the user do so manually.
else else
printf "I can't change your shell automatically because this system does not have chsh.\n" printf "I can't change your shell automatically because this system does not have chsh.\n"