mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-12 20:21:02 +01:00
installer: use default color sequences on missing tput
Supposed to be POSIX-compatible. Proved to work in dash, yash and whatever alpine uses. See https://unix.stackexchange.com/a/371873
This commit is contained in:
parent
220d69b2ce
commit
153f5e11ed
1 changed files with 17 additions and 17 deletions
|
@ -27,7 +27,7 @@ command_exists() {
|
||||||
}
|
}
|
||||||
|
|
||||||
error() {
|
error() {
|
||||||
echo "Error: $@" >&2
|
echo ${RED}"Error: $@"${RESET} >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set up color sequences
|
# Set up color sequences
|
||||||
|
@ -45,14 +45,14 @@ setup_color() {
|
||||||
YELLOW="$(tput setaf 3)"
|
YELLOW="$(tput setaf 3)"
|
||||||
BLUE="$(tput setaf 4)"
|
BLUE="$(tput setaf 4)"
|
||||||
BOLD="$(tput bold)"
|
BOLD="$(tput bold)"
|
||||||
NORMAL="$(tput sgr0)"
|
RESET="$(tput sgr0)"
|
||||||
else
|
else
|
||||||
RED=""
|
RED=$(printf '\033[31m')
|
||||||
GREEN=""
|
GREEN=$(printf '\033[32m')
|
||||||
YELLOW=""
|
YELLOW=$(printf '\033[33m')
|
||||||
BLUE=""
|
BLUE=$(printf '\033[34m')
|
||||||
BOLD=""
|
BOLD=$(printf '\033[1m')
|
||||||
NORMAL=""
|
RESET=$(printf '\033[m')
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ setup_ohmyzsh() {
|
||||||
# precedence over umasks except for filesystems mounted with option "noacl".
|
# precedence over umasks except for filesystems mounted with option "noacl".
|
||||||
umask g-w,o-w
|
umask g-w,o-w
|
||||||
|
|
||||||
echo "${BLUE}Cloning Oh My Zsh...${NORMAL}"
|
echo "${BLUE}Cloning Oh My Zsh...${RESET}"
|
||||||
|
|
||||||
command_exists git || {
|
command_exists git || {
|
||||||
error "git is not installed"
|
error "git is not installed"
|
||||||
|
@ -84,13 +84,13 @@ setup_ohmyzsh() {
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_zshrc() {
|
setup_zshrc() {
|
||||||
echo "${BLUE}Looking for an existing zsh config...${NORMAL}"
|
echo "${BLUE}Looking for an existing zsh config...${RESET}"
|
||||||
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
|
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
|
||||||
echo "${YELLOW}Found ~/.zshrc.${GREEN} Backing up to ~/.zshrc.pre-oh-my-zsh.${NORMAL}"
|
echo "${YELLOW}Found ~/.zshrc.${GREEN} Backing up to ~/.zshrc.pre-oh-my-zsh.${RESET}"
|
||||||
mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh
|
mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${BLUE}Using the Oh My Zsh template file and adding it to ~/.zshrc.${NORMAL}"
|
echo "${BLUE}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\\
|
||||||
|
@ -109,12 +109,12 @@ setup_shell() {
|
||||||
if ! command_exists chsh; then
|
if ! command_exists chsh; then
|
||||||
cat <<-EOF
|
cat <<-EOF
|
||||||
I can't change your shell automatically because this system does not have chsh.
|
I can't change your shell automatically because this system does not have chsh.
|
||||||
${BLUE}Please manually change your default shell to zsh${NORMAL}
|
${BLUE}Please manually change your default shell to zsh${RESET}
|
||||||
EOF
|
EOF
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${BLUE}Time to change your default shell to zsh!${NORMAL}"
|
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
|
||||||
|
@ -146,13 +146,13 @@ main() {
|
||||||
setup_color
|
setup_color
|
||||||
|
|
||||||
if ! command_exists zsh; then
|
if ! command_exists zsh; then
|
||||||
echo "${YELLOW}Zsh is not installed.${NORMAL} Please install zsh first."
|
echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d "$ZSH" ]; then
|
if [ -d "$ZSH" ]; then
|
||||||
cat <<-EOF
|
cat <<-EOF
|
||||||
${YELLOW}You already have Oh My Zsh installed.${NORMAL}
|
${YELLOW}You already have Oh My Zsh installed.${RESET}
|
||||||
You'll need to remove '$ZSH' if you want to reinstall.
|
You'll need to remove '$ZSH' if you want to reinstall.
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -179,7 +179,7 @@ main() {
|
||||||
p.p.s. Get stickers, shirts, and coffee mugs at https://shop.planetargon.com/collections/oh-my-zsh
|
p.p.s. Get stickers, shirts, and coffee mugs at https://shop.planetargon.com/collections/oh-my-zsh
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
printf "$NORMAL"
|
printf "$RESET"
|
||||||
|
|
||||||
exec zsh -l
|
exec zsh -l
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue