一蒸痹、安裝oh my zsh
1. zsh是什么春弥???
Zsh
是一款強(qiáng)大的虛擬終端呛哟,既是一個(gè)系統(tǒng)的虛擬終端,也可以作為一個(gè)腳本語(yǔ)言的交互解析器惕稻。
2. 如何查看是否安裝了zsh竖共???
- 在終端輸入:
$ zsh --version
- 我的輸出:
zsh 5.7.1 (x86_64-apple-darwin19.0)
這表示我已經(jīng)安裝了zsh
3. oh my zsh
① 安裝
可以通過(guò) curl
或 wget
兩種方式來(lái)安裝,用一條命令即可安裝俺祠。
- curl安裝
$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
- wget安裝
$ sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
② 簡(jiǎn)單配置
設(shè)置固定主題
- 終端輸入:
open ~/.zshrc
- 找到
ZSH_THEME="robbyrussell"
,這里公给,已經(jīng)設(shè)置了默認(rèn)主題robbyrussell
,若要修改主題請(qǐng)按此格式:ZSH_THEME="主題名稱"
- 保存文件,重新打開(kāi)終端
設(shè)置隨機(jī)主題
- 終端輸入:
open ~/.zshrc
- 主題設(shè)置為:
ZSH_THEME="random"
- 這樣每次打開(kāi)終端時(shí)蜘渣,主題都是隨機(jī)的淌铐。
- 例:下一次打開(kāi)終端時(shí),會(huì)輸出形如
[oh-my-zsh] Random theme 'xiong-chiamiov' loaded
的語(yǔ)句蔫缸,'xiong-chiamiov'即主題名稱腿准,如果你喜歡這個(gè)主題,可以把它設(shè)置在你的.zshrc中拾碌。
查看主題名稱
oh my zsh
默認(rèn)自帶了一些默認(rèn)主題吐葱,存放在 ~/.oh-my-zsh/themes
目錄中。我們可以查看這些主題:
$ cd ~/.oh-my-zsh/themes && ls
③ 卸載oh my zsh
$ uninstall_oh_my_zsh
Are you sure you want to remove Oh My Zsh? [y/N] Y
④ oh my zsh 的自動(dòng)更新提示誤觸關(guān)掉了解決辦法
$ upgrade_oh_my_zsh
二校翔、安裝autojump
插件功能:實(shí)現(xiàn)目錄間快速跳轉(zhuǎn)志鹃,想去哪個(gè)目錄直接 j + 目錄名耀盗,不用再頻繁的 cd 了!
1. 安裝步驟
- 在終端輸入:
$ brew install autojump
- 輸出:
==> Downloading https://homebrew.bintray.com/bottles/autojump-22.5.3.catalina.bo
######################################################################## 100.0%
==> Pouring autojump-22.5.3.catalina.bottle.tar.gz
==> Caveats
Add the following line to your ~/.bash_profile or ~/.zshrc file (and remember
to source the file to update your current session):
[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
If you use the Fish shell then add the following line to your ~/.config/fish/config.fish:
[ -f /usr/local/share/autojump/autojump.fish ]; and source /usr/local/share/autojump/autojump.fish
zsh completions have been installed to:
/usr/local/share/zsh/site-functions
==> Summary
?? /usr/local/Cellar/autojump/22.5.3: 20 files, 169.3KB
image.png
- 根據(jù)提示,在
~/.zshrc
文件中加入:
[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
- 使用
source
命令更新配置文件:
$ source ~/.zshrc
- 這樣就可以根據(jù)你的
cd
歷史記錄灰粮,使用j
命令快速跳轉(zhuǎn)到目標(biāo)目錄孝冒,而不需要多次cd
啦~
三添履、安裝zsh-syntax-highlighting
插件功能:這個(gè)包為
shell zsh
提供語(yǔ)法突出顯示驻谆。它允許高亮顯示在zsh
提示符下輸入到交互式終端的命令。這有助于在運(yùn)行命令之前檢查它們奈嘿,特別是在捕獲語(yǔ)法錯(cuò)誤方面貌虾。
例:在你輸入某個(gè)命令時(shí),如果該命令不存在裙犹,那么它顯示為紅色酝惧;否則,它會(huì)變成綠色伯诬。
1. 文檔
2. 安裝步驟
- 在終端輸入:
$ brew install zsh-syntax-highlighting
- 輸出:
==> Downloading https://homebrew.bintray.com/bottles/zsh-syntax-highlighting-0.7.1.catal
######################################################################## 100.0%
==> Pouring zsh-syntax-highlighting-0.7.1.catalina.bottle.tar.gz
==> Caveats
To activate the syntax highlighting, add the following at the end of your .zshrc:
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
If you receive "highlighters directory not found" error message,
you may need to add the following to your .zshenv:
export ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR=/usr/local/share/zsh-syntax-highlighting/highlighters
==> Summary
?? /usr/local/Cellar/zsh-syntax-highlighting/0.7.1: 27 files, 164.4KB
image.png
- 在
~/.zshrc
文件中加入:
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
- 使用
source
命令更新配置文件:
$ source ~/.zshrc
四晚唇、安裝zsh-autosuggestion
插件功能:輸入命令時(shí)可提示自動(dòng)補(bǔ)全(灰色部分),按tab鍵(→ )即可補(bǔ)全盗似。
1. 文檔:
2. 安裝步驟
- 在終端輸入:
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
- 輸出:
Cloning into '/Users/xxx/.zsh/zsh-autosuggestions'...
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 2396 (delta 2), reused 3 (delta 1), pack-reused 2385
Receiving objects: 100% (2396/2396), 545.28 KiB | 5.00 KiB/s, done.
Resolving deltas: 100% (1533/1533), done.
- 在
~/.zshrc
s文件中加入:
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
- 使用
source
命令更新配置文件:
$ source ~/.zshrc