我用的是騰訊雲服務器,安裝的 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