zsh安裝powerlevel10k樣式


安裝Nerd Fonts字體

MacOS

方式一:

# https://github.com/ryanoasis/nerd-fonts#option-4-homebrew-fonts
brew tap caskroom/fonts #字體安裝軟體,只需執行一次以後就可以去下載其他字體
brew cask install font-hack-nerd-font # 安裝字體

方式二:

cd ~/Library/Fonts && curl -fLo "Droid Sans Mono for Powerline Nerd Font Complete.otf" https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DroidSansMono/complete/Droid%20Sans%20Mono%20Nerd%20Font%20Complete.otf

客戶端設置字體

Iterm2 里配置非 acsii 字體,否則對於 powerlevel10k 主題的特殊字體會顯示不出來。

(Iterm2 -> Preferences -> Profiles -> Text -> Non-Ascii-Font 選擇 nerd-font and restart Iterm2), 之后重啟 Iterm2 生效

Linux

方式一:

git clone https://github.com/ryanoasis/nerd-fonts.git --depth 1
cd nerd-fonts 
./install.sh
cd ..
rm -rf nerd-fonts

安裝完后,終端客戶端需要選擇名字帶 nerd fonts 的字體

上述方式非常不友好,完全下載,整個包有1G

方式二:

mkdir -p ~/.local/share/fonts
cd ~/.local/share/fonts && curl -fLo "Droid Sans Mono for Powerline Nerd Font Complete.otf" https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DroidSansMono/complete/Droid%20Sans%20Mono%20Nerd%20Font%20Complete.otf

生成字體信息緩存

fc-cache -vf ~/.local/share/fonts/

查看是否安裝成功

fc-list | grep -i droid
/home/kylin/.local/share/fonts/Droid Sans Mono for Powerline Nerd Font Complete.otf: DroidSansMonoForPowerline Nerd Font:style=Book

Windows

方式一:

官網下載直接安裝

官網地址

方式二:

使用 Nerd Fonts https://github.com/ryanoasis/nerd-fonts 字體庫里面的字體(Powerline Fonts https://github.com/powerline/fonts 字體庫里面的字體估計也行,還沒試過)。Windows Terminal 默認的字體為 Cascadia Code,在 Nerd Fonts 倉庫找到了 Cascadia Code 的打補丁字體 Caskaydia Cove Nerd Font*,下載並安裝 Caskaydia Cove Regular Nerd Font Complete Windows Compatible.ttf

Windows 字體相關知識

  • 用戶安裝的字體都存放在 C:\Users\<用戶名>\AppData\Local\Microsoft\Windows\Fonts 目錄下,為所有用戶安裝的字體存放在 C:\Windows\fonts 目錄下
  • 字體管理,在『設置 --> 個性化 --> 字體』中可以搜索並卸載字體,等同於在C:\Windows\fonts 目錄下搜索並刪除字體
  • 注意:在 C:\Users\<用戶名>\AppData\Local\Microsoft\Windows\Fonts 目錄下刪除安裝的字體會報錯,因為 C:\Windows\fonts 目錄下存有 C:\Users\<用戶名>\AppData\Local\Microsoft\Windows\Fonts 中的字體引用,所以刪除/卸載字體,應去C:\Windows\fonts 目錄下執行

客戶端設置字體

window-terminal中設置字體:

profiles中設置

"fontFace":"CaskaydiaCove NF",

"fontFace":"Hack Nerd Font Mono",

安裝powerlevel10k

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k

p10k configure

修改zsh樣式配置

ZSH_THEME="powerlevel10k/powerlevel10k"

source ~/.zshrc

powerlevel10k主題配置

#ZSH_THEME=powerlevel10k/powerlevel10k

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir vcs pyenv)
POWERLEVEL9K_MODE='nerdfont-complete'
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR=''
POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR=''
POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR=''
POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR=''
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="%F{blue}\u256D\u2500%F{white}"
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%F{blue}\u2570\uf460%F{white} "
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(root_indicator dir dir_writable_joined)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(command_execution_time
                                    vcs background_jobs_joined time_joined)
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND="clear"
POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND="clear"
POWERLEVEL9K_VCS_MODIFIED_FOREGROUND="yellow"
POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND="yellow"
POWERLEVEL9K_DIR_HOME_BACKGROUND="clear"
POWERLEVEL9K_DIR_HOME_FOREGROUND="blue"
POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND="clear"
POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND="blue"
POWERLEVEL9K_DIR_WRITABLE_FORBIDDEN_BACKGROUND="clear"
POWERLEVEL9K_DIR_WRITABLE_FORBIDDEN_FOREGROUND="red"
POWERLEVEL9K_DIR_DEFAULT_BACKGROUND="clear"
POWERLEVEL9K_DIR_DEFAULT_FOREGROUND="white"
POWERLEVEL9K_ROOT_INDICATOR_BACKGROUND="red"
POWERLEVEL9K_ROOT_INDICATOR_FOREGROUND="white"
POWERLEVEL9K_STATUS_OK_BACKGROUND="clear"
POWERLEVEL9K_STATUS_OK_FOREGROUND="green"
POWERLEVEL9K_STATUS_ERROR_BACKGROUND="clear"
POWERLEVEL9K_STATUS_ERROR_FOREGROUND="red"
POWERLEVEL9K_TIME_BACKGROUND="clear"
POWERLEVEL9K_TIME_FOREGROUND="cyan"
POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND='clear'
POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND='magenta'
POWERLEVEL9K_BACKGROUND_JOBS_BACKGROUND='clear'
POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND='green'

參考

nerd-fonts

Centos7通過oh-my-zsh安裝powerlevel9k和powerlevel10k

PegasusWang/linux_config


免責聲明!

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



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