ubuntu zsh 自动安装脚本
#!/bin/bash
function log() {
echo $(date -u '+%Y-%m-%dT%H:%M:%S')" INFO: "$@
}
returnCode=`which zsh`
user=`whoami`
if [[ returnCode != "0" ]]; then
log "install zsh start" && sudo apt-get install -y zsh && log "install zsh end"
else
log "zsh installed"
fi
log "install oh-my-zsh" && cd /home/$user && sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" && log "install oh-my-zsh end"
# 安装zsh-syntax-highlighting,输入的命令中间有错的时候会自动显示红色
log "install zsh-syntax-highlighting" && git clone https://github.com/zsh-users/zsh-syntax-highlighting.git /home/$user/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting && log "install zsh-syntax-highlighting end"
# 安装zsh-autosuggestions,记录经常用的一些命令并进行提示
log "install zsh-autosuggestions" && git clone https://github.com/zsh-users/zsh-autosuggestions.git /home/$user/.oh-my-zsh/custom/plugins/zsh-autosuggestions && log "install zsh-autosuggestions end"
# 添加插件到 .zshrc 中
log "add plugs in .zshrc" && sed -i 's/^plugins=(git)/plugins=(git zsh-syntax-highlighting zsh-autosuggestions)/g' /home/$user/.zshrc && log "add plugs in .zshrc end"
# 启动zsh
log "start zsh" && zsh