CentOS 7.x 安裝 ZSH 終端


一、安裝基本組件

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

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

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

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

    chsh -s /usr/bin/zsh
    

二、進行可選配置

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-autosuggestions

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

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

完成克隆操作之后,那么兩個插件的全路徑分別是:

/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 文件。

# 其他內容
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 配置,最后的效果如下圖。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM