Debian安裝zsh和oh-my-zsh


Linux下安裝zsh和oh-my-zsh

系統:Debian 10.5 (阿里雲)

工具:Xshell 6 (Build 0206)

1.Zsh的介紹

Zsh(Z-shell)是一款用於交互式使用的shell,也可以作為腳本解釋器來使用。其包含了 bash,ksh,tcsh 等其他shell中許多優秀功能,也擁有諸多自身特色。

從 macOS Catalina 版開始,其默認shell從bash改為zsh。

2.安裝Zsh

sudo apt-get update
sudo apt-get install zsh
chsh -s /bin/zsh #將zsh替換為你的默認shell

image-20210727141220871

3.安裝git(如有請忽略此步)

sudo apt-get install git

4.安裝oh-my-zsh

默認的 Zsh 配置有點麻煩。因此一個叫 robbyrussel 的用戶在 GitHub 上制作了一個配置文件 oh-my-zsh,這是目前為止最流行的 Zsh 配置:https://github.com/ohmyzsh/ohmyzsh

安裝教程在上面倉庫的readme文件中有描述(這里以使用curl為例)

方式 命令
curl sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
wget sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fetch sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

image-20210727142721746

5.主題配置

下載完oh-my-zsh后的默認主題【robbyrussell】效果如上一步效果圖

主題詳細預覽參考倉庫中的wiki

https://github.com/robbyrussell/oh-my-zsh/wiki/themes

打開配置文件【~/.zshrc】,直接更改目標位置(esc后鍵入冒號輸入/ZSH_THEME檢索)的字符串即可

image-20210727142921803

例如配置成【xiong-chiamiov-plus】

ZSH_THEME="xiong-chiamiov-plus"

image-20210727143312961

6.插件配置

同樣插件在倉庫wiki也有描述

https://github.com/ohmyzsh/ohmyzsh/wiki/plugins

打開配置文件【~/.zshrc】,直接在目標位置(esc后鍵入冒號輸入/plugins檢索)的括號中添加即可

image-20210727143938921

其實需要哪個插件就在~/.oh-my-zsh/custom/plugins/中克隆哪個倉庫就行了

https://github.com/zsh-users

例如通過上方倉庫添加代碼高亮與自動補全

cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh-autosuggestions.git #自動補全
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git #代碼高亮

image-20210727144518803

然后將這兩個插件添加到【~/.zshrc】中

image-20210727144839567

補全和高亮成功設置

image-20210727144915383


免責聲明!

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



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