什么是zsh
ZSH也稱為Z Shell,是Bourne Shell(sh)的擴展版本岛心,具有許多新功能琳钉,并支持插件和主題舀患。 由于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ū)動的框架,用于管理欢搜。
oh my zsh的安裝
- 參考官網(wǎng)的安裝方法
jiahui@ubuntu:~$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
相關(guā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)
)
部分插件需要單獨下載到 ~/.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)提示:
- 安裝推薦的字體疮装,可選缘琅,但強烈建議。
- 下載下面4個ttf文件:
- 雙擊文件廓推,然后點擊安裝即可刷袍。
- 配置終端使用這個字體,以GNUME Terimal(默認(rèn)的ubantu終端)為例:Open Terminal → Preferences and click on the selected profile under Profiles. Check Custom font under Text Appearance and select MesloLGS NF Regular.
- 安裝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"
- 使用exec Zsh重新啟動Zsh
╭─ ? ? ~/.oh-my-zsh/custom/themes on ? ? master ? INT at ? 14:49:14 ─╮
╰─? exec zsh
- 如果配置向?qū)]有自動啟動樊展,請鍵入p10k configure
╭─ ? ? ~/.oh-my-zsh/custom/themes on ? ? master ? INT at ? 14:52:43 ─╮
╰─? p10k configure
- 按照對應(yīng)的配置向?qū)Ъ纯赏瓿蓪僮约旱闹黝}配置呻纹,如果覺得不好,請鍵入p10k configure重新配置
卸載
uninstall_oh_my_zsh