2018-10-09 13:54:15 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-07-12 10:17:32 +08:00
|
|
|
###################################################################################
|
|
|
|
# 控制台颜色
|
|
|
|
BLACK="\033[1;30m"
|
|
|
|
RED="\033[1;31m"
|
|
|
|
GREEN="\033[1;32m"
|
|
|
|
YELLOW="\033[1;33m"
|
|
|
|
BLUE="\033[1;34m"
|
|
|
|
PURPLE="\033[1;35m"
|
|
|
|
CYAN="\033[1;36m"
|
|
|
|
RESET="$(tput sgr0)"
|
|
|
|
###################################################################################
|
|
|
|
|
|
|
|
printf "${BLUE}"
|
2019-05-07 14:29:16 +08:00
|
|
|
cat << EOF
|
|
|
|
|
2018-10-09 13:54:15 +08:00
|
|
|
###################################################################################
|
|
|
|
# 安装 zsh、oh-my-zsh 脚本
|
2019-05-07 14:29:16 +08:00
|
|
|
# @system: 适用于 CentOS
|
|
|
|
# @author: Zhang Peng
|
|
|
|
# See: https://github.com/robbyrussell/oh-my-zsh
|
2018-10-09 13:54:15 +08:00
|
|
|
###################################################################################
|
|
|
|
|
2019-05-07 14:29:16 +08:00
|
|
|
EOF
|
2019-07-12 10:17:32 +08:00
|
|
|
printf "${RESET}"
|
2018-10-09 13:54:15 +08:00
|
|
|
|
2019-07-12 15:53:54 +08:00
|
|
|
printf "${GREEN}>>>>>>>> install zsh begin.${RESET}\n"
|
2019-05-09 11:26:06 +08:00
|
|
|
|
2019-10-29 18:22:19 +08:00
|
|
|
command -v yum > /dev/null 2>&1 || {
|
|
|
|
printf "${RED}Require yum but it's not installed.${RESET}\n";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
command -v git > /dev/null 2>&1 || {
|
|
|
|
printf "${RED}Require git but it's not installed.${RESET}\n";
|
|
|
|
exit 1;
|
|
|
|
}
|
2019-05-07 14:29:16 +08:00
|
|
|
|
2019-07-12 10:17:32 +08:00
|
|
|
# install zsh
|
|
|
|
yum install -y zsh
|
2019-07-12 15:53:54 +08:00
|
|
|
chsh -s /bin/zsh
|
2019-07-12 10:17:32 +08:00
|
|
|
# install oh-my-zsh
|
2020-04-02 10:07:17 +08:00
|
|
|
# 由于国内经常无法使用 sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
|
|
|
# 所以,索性将安装脚本下载下来直接使用
|
|
|
|
#curl -o- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | bash
|
|
|
|
zsh/oh-my-zsh-install.sh
|
2019-07-12 10:17:32 +08:00
|
|
|
# choose oh-my-zsh theme
|
|
|
|
sed -i "s/^ZSH_THEME=.*/ZSH_THEME=\"ys\"/g" ~/.zshrc
|
|
|
|
# install oh-my-zsh plugins
|
|
|
|
git clone https://github.com/zsh-users/zsh-autosuggestions.git ~/.oh-my-zsh/plugins/zsh-autosuggestions
|
|
|
|
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/plugins/zsh-syntax-highlighting
|
|
|
|
sed -i "s/^plugins=.*/plugins=(git z wd extract zsh-autosuggestions zsh-syntax-highlighting)/g" ~/.zshrc
|
|
|
|
# reload zsh
|
2020-04-02 10:07:17 +08:00
|
|
|
# 注册到 /etc/shells
|
|
|
|
echo "/usr/bin/zsh" >> /etc/shells
|
|
|
|
# 切换 shell
|
|
|
|
chsh -s $(which zsh)
|
2019-07-12 15:53:54 +08:00
|
|
|
printf "${GREEN}<<<<<<<< install zsh finished${RESET}\n"
|
|
|
|
printf "${GREEN}Please reboot to take effect.${RESET}\n"
|