文章目錄
效果圖
- macos
前面有個可愛的蘋果小圖標,cd
命令 顏色高亮顯示, 後面灰色的tessera
目錄爲上次輸入過的目錄,按➡️直接填充 - ubuntu
安裝zsh
虛擬終端,兼容bash
- macos
mac默認已經安裝了zsh,只需切換
chsh -s /bin/zsh
如果想還原回去執行chsh -s /bin/bash
即可
- ubuntu
sudo apt install zsh
chsh -s /bin/zsh
安裝oh-my-zsh
基於zsh命令行,是對zsh的包裝,提供了主題配置,插件機制.
curl
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
wget
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
安裝Powerlevel9k / Powerlevel10k主題
zsh使用最多的主題
git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
編輯 ~/.zshrc
設置 ZSH_THEME="powerlevel10k/powerlevel10k".
再增加一行配置:POWERLEVEL9K_MODE="awesome-patched"
安裝字體
- ubuntu
apt-get install fonts-powerline
- macos
https://github.com/powerline/fonts/blob/master/SourceCodePro/Source%20Code%20Pro%20for%20Powerline.otf
https://github.com/Falkor/dotfiles/blob/master/fonts/SourceCodePro%2BPowerline%2BAwesome%2BRegular.ttf
打開下載的字體,然後按“安裝字體”。
在iTerm2中設置字體(Preperence->Profiles->Text→Change Font),選擇Source Code Pro + Font Awesome
,大小18,最好對“字體”和“非ASCII字體”都進行設置。重新啓動iTerm2,以使所有更改生效.
zsh配置主題
source ~/.zshrc
或者執行下面的命令,重新配置
p10k configure
開始配置Powerlevel10k,根據提示(喜好)選擇1234或yes、no
iterm2主題配置(針對mac)
下載主題:https://iterm2colorschemes.com
Preperence->Profiles->Colors->color Presets,點擊import,選擇剛解壓的目錄,點擊目錄下的schemes,選擇你想要導入的主題(可多選全部導入),導入後選擇自己喜歡的主題,這裏我選擇了ubuntu主題
一些常用的插件
zsh-autosuggestions
下載插件
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
編輯 ~/.zshrc
,設置plugins
plugins=(zsh-autosuggestions git)
使插件生效
source ~/.zshrc
上次敲過的命令 ,會自動提示,按右方向鍵➡️確認填充上次的命令
zsh-syntax-highlighting
下載插件
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
寫入到配置
echo "source $ZSH_CUSTOM/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
使插件生效
source ~/.zshrc
命令會自動高亮顯示