我用的是腾讯云服务器,安装的 Centos 7 系统,下面是安装的教程和遇到的问题解决办法:
一、安装步骤:
1.安装zsh
yum install zsh
2.安装git
yum install git
3.下载`oh-my-zsh`的安装脚本
- 安装wget(centos7默认是没有的)
yum install wget
4.下载 zsh 安装脚本
- 我这里因为用 github 源无法下载,一直卡在 clone into "xxx",所以改换了国内的镜像源
# gitee 源 wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh
5.编辑 install.sh
找到以下部分
# Default settings ZSH=${ZSH:-~/.oh-my-zsh} REPO=${REPO:-ohmyzsh/ohmyzsh} REMOTE=${REMOTE:-https://github.com/${REPO}.git} BRANCH=${BRANCH:-master}
把
REPO=${REPO:-ohmyzsh/ohmyzsh} REMOTE=${REMOTE:-https://github.com/${REPO}.git}
替换为
REPO=${REPO:-mirrors/oh-my-zsh} REMOTE=${REMOTE:-https://gitee.com/${REPO}.git}
6. 编辑后保存, 运行安装即可. (运行前先给install.sh权限)
# 赋予可执行权限 chomd +x install.sh # 运行 sh install.sh
7. 修改仓库地址
cd ~/.oh-my-zsh git remote set-url origin https://gitee.com/mirrors/oh-my-zsh.git git pull
二、切换为 zsh
1. 输入`cat /etc/shells`命令来查看本地安装的shell
/bin/sh /bin/bash /usr/bin/sh /usr/bin/bash /bin/tcsh /bin/csh /bin/zsh
2. 切换sehll至zsh
chsh -s /bin/zsh
3. 查看当前使用的shell
echo $SHELL
三、oh-my-zsh插件设置
1. 编辑主题和插件
vim ~/.zshrc
- 修改主题:找到下面设置主题的部分,修改引号中的名称即可(比如我这里用的 ys 主题)
ZSH_THEME="ys"
- 修改插件:找到插件的部分,直接修改,常用的插件可以自行参考网上其他文章
plugins=(git sublime z web-search wd zsh-autosuggestions extract zsh-syntax-highlighting)
2. 刷新配置文件
source ~/.zshrc
- 在刷新配置的过程中,提示zsh-autosuggestions、zsh-syntax-highlighting 插件 not found,可通过单独下载解决(下载后再次刷新配置文件):
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting