CentOS 7.x 安裝 ZSH 終端

1、安裝基本組件

  1. 首先執行 yum 命令來安裝須要的 zsh 原始程序與 git 程序來 pull 代碼。git

    yum install -y zsh git
  2. 安裝 oh my zsh 腳本 (這一步須要安裝 git)。github

    wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
  3. 使用 which zsh 查看 zsh 的安裝目錄,通常都存儲在 /usr/bin/zsh 目錄下。shell

    which zsh
  4. 使用 chsh 命令切換使用的 shell 程序。工具

    chsh -s /usr/bin/zsh

2、進行可選配置

2.1 安裝 ZSH 圖標字體

執行如下命令在當前目錄拉取圖標的倉庫,並切換到其目錄下,執行 ./install.sh 腳本便可安裝成功。字體

git clone https://github.com/powerline/fonts.git

2.2 更換 ZSH 主題

使用 vi 工具編輯 /root/.zshrc 文件,更改 ZSH_THEME="robbyussell" 字段爲 ZSH_THEME="agnoster" 字段,並經過 source ~/.zshrc 命令更新它們的配置文件。插件

2.3 安裝插件

使用 ZSH 替換原有的 SHELL 最主要的緣由就是要使用其功能強大的插件,這裏只推薦安裝三個插件,它們分別是 wdzsh-syntax-highlightingzsh-autosuggestionscode

首先依次執行下列的命令,將後面兩個插件的倉庫克隆到 Oh My Zsh 的插件目錄下。blog

cd ~/.oh-my-zsh/custom/plugins
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
git clone https://github.com/zsh-users/zsh-autosuggestions.git

完成克隆操做以後,那麼兩個插件的全路徑分別是:get

/root/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-syntax-highlighting.zsh
/root/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh

繼續使用 vi 編輯 ~/.zshrc 文件。it

# 其餘內容
plugins=(
  git
  wd
  zsh-syntax-highlighting
  zsh-autosuggestions
)

source /root/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /root/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source $ZSH/oh-my-zsh.sh
# 其餘內容

編輯完成以後,執行 source ~/.zshrc 命令更新 ZSH 配置,最後的效果以下圖。

相關文章
相關標籤/搜索