1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-18 11:50:07 +00:00

installer: improve message formatting and color

This commit is contained in:
Marc Cornellà 2019-05-28 18:34:58 +02:00
parent b931d6a9db
commit 66d6d08841

View file

@ -101,6 +101,8 @@ setup_ohmyzsh() {
error "git clone of oh-my-zsh repo failed" error "git clone of oh-my-zsh repo failed"
exit 1 exit 1
} }
echo
} }
setup_zshrc() { setup_zshrc() {
@ -128,13 +130,15 @@ setup_zshrc() {
mv ~/.zshrc "$OLD_ZSHRC" mv ~/.zshrc "$OLD_ZSHRC"
fi fi
echo "${BLUE}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}" echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}"
cp "$ZSH/templates/zshrc.zsh-template" ~/.zshrc cp "$ZSH/templates/zshrc.zsh-template" ~/.zshrc
sed "/^export ZSH=/ c\\ sed "/^export ZSH=/ c\\
export ZSH=\"$ZSH\" export ZSH=\"$ZSH\"
" ~/.zshrc > ~/.zshrc-omztemp " ~/.zshrc > ~/.zshrc-omztemp
mv -f ~/.zshrc-omztemp ~/.zshrc mv -f ~/.zshrc-omztemp ~/.zshrc
echo
} }
setup_shell() { setup_shell() {
@ -157,7 +161,7 @@ setup_shell() {
return return
fi fi
echo "${BLUE}Time to change your default shell to zsh!${RESET}" echo "${BLUE}Time to change your default shell to zsh:${RESET}"
# Test for the right location of the "shells" file # Test for the right location of the "shells" file
if [ -f /etc/shells ]; then if [ -f /etc/shells ]; then
@ -174,7 +178,8 @@ setup_shell() {
# 2. If that fails, get a zsh path from the shells file, then check it actually exists # 2. If that fails, get a zsh path from the shells file, then check it actually exists
if ! zsh=$(which zsh) || ! grep -qx "$zsh" "$shells_file"; then if ! zsh=$(which zsh) || ! grep -qx "$zsh" "$shells_file"; then
if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -1) || [ ! -f "$zsh" ]; then if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -1) || [ ! -f "$zsh" ]; then
error "no available zsh binary found. Change your default shell manually." error "no zsh binary found or not present in '$shells_file'"
error "change your default shell manually."
return return
fi fi
fi fi
@ -182,7 +187,12 @@ setup_shell() {
# Actually change the default shell to zsh # Actually change the default shell to zsh
if ! chsh -s "$zsh"; then if ! chsh -s "$zsh"; then
error "chsh command unsuccessful. Change your default shell manually." error "chsh command unsuccessful. Change your default shell manually."
else
export SHELL="$zsh"
echo "${GREEN}Shell successfully changed to '$zsh'.${RESET}"
fi fi
echo
} }
main() { main() {