強(qiáng)大的虛擬終端zsh以及oh my zsh管理框架

什么是zsh

ZSH也稱為Z Shell,是Bourne Shell(sh)的擴(kuò)展版本,具有許多新功能,并支持插件和主題。 由于ZSH與Bash基于相同的外殼,因此ZSH具有許多相同的功能,并且切換起來非常容易。

zsh的安裝

  • ubantu20.04下安裝非常容易,直接apt install即可,然后查看系統(tǒng)中的全部shell中出現(xiàn)zsh代表安裝成功
jiahui@ubuntu:~$ sudo apt install zsh

jiahui@ubuntu:~$ zsh --version
zsh 5.8 (x86_64-ubuntu-linux-gnu)

jiahui@ubuntu:~$ cat /etc/shells 
/bin/sh
/bin/bash
/bin/rbash
/bin/dash
/bin/zsh
/usr/bin/zsh
  • 設(shè)置zsh為默認(rèn)的shell
jiahui@ubuntu:~$ chsh -s /bin/zsh 
jiahui@ubuntu:~$ reboot 
  • 查看是否已經(jīng)設(shè)置稱為默認(rèn)的shell
jiahui@ubuntu:~$ echo $SHELL
/bin/zsh

什么是 oh my zsh

打開oh my zsh的官網(wǎng),如同官網(wǎng)所說,Oh My Zsh是一開源的,社區(qū)驅(qū)動(dòng)的框架,用于管理。

oh my zsh的安裝

jiahui@ubuntu:~$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

相關(guān)的插件安裝

打開配置文件,添加想要的插件,就可以進(jìn)行相關(guān)插件的安裝了

 ~ sudo gedit ~/.zshrc
  • 插件設(shè)置
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)

保存退出后在終端輸入

source ~/.zshrc 

插件概述

Plugins Overview有相關(guān)的概述

插件推薦

分享出自己的plugins的設(shè)置

plugins=(
git #extras: git-extras gitfast git-flow git-flow-avh git-hubflow git-remote-branch
extract #'x' alias - swiss knife for archive extracting
z #yet another autojump
history #aliases: h for history, hsi for grepping history
rand-quote #quote function for random quotes from [https://www.quotationspage.com/random.php](https://www.quotationspage.com/random.php)
themes #ZSH theme switcher
cp #cp with progress bar (rsync)
colored-man-pages #adds colors to manpages
battery #allows see battery status in PS

# The following plug-ins need to be installed separately. Clone the corresponding git repository to the corresponding directory: ~/.oh-my-zsh/custom/plugins
zsh-syntax-highlighting #Fish shell-like syntax highlighting for Zsh(https://github.com/zsh-users/zsh-syntax-highlighting)
zsh-autosuggestions #It suggests commands as you type based on history and completions (https://github.com/zsh-users/zsh-autosuggestions)
git-open #Type git open to open the repo website (GitHub, GitLab, Bitbucket) in your browser.(https://github.com/paulirish/git-open)
)

部分插件需要單獨(dú)下載到 ~/.oh-my-zsh/custom/plugins目錄下


相關(guān)主題的設(shè)置

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="powerlevel10k/powerlevel10k"

相關(guān)主題的安裝

要說到什么主題最好用,那當(dāng)然是powerlevel10k。先來上一張主題的照片

安裝方法,參照官網(wǎng)提示:

  1. 安裝推薦的字體,可選,但強(qiáng)烈建議。
  1. 安裝Powerlevel10k
  • 將倉庫克隆到~/.oh-my-zsh/custom/themes
╭─ ?  ?  ~/.oh-my-zsh/custom/themes on ?  ? master                                                                           at ?  14:47:39 ─╮
╰─? git clone https://github.com/romkatv/powerlevel10k.git 
  • 修改zshrc配置文件
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="powerlevel10k/powerlevel10k"
  1. 使用exec Zsh重新啟動(dòng)Zsh
╭─ ?  ?  ~/.oh-my-zsh/custom/themes on ?  ? master                                                                     ? INT at ?  14:49:14 ─╮
╰─? exec zsh  
  1. 如果配置向?qū)]有自動(dòng)啟動(dòng),請(qǐng)鍵入p10k configure
╭─ ?  ?  ~/.oh-my-zsh/custom/themes on ?  ? master                                                                     ? INT at ?  14:52:43 ─╮
╰─? p10k configure 
  1. 按照對(duì)應(yīng)的配置向?qū)Ъ纯赏瓿蓪僮约旱闹黝}配置,如果覺得不好,請(qǐng)鍵入p10k configure重新配置

卸載

uninstall_oh_my_zsh
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容