[TOC] #### 1. 介紹 --- 前提:本文使用的終端 shell 是 zsh,并且已經(jīng)安裝了 Oh My Zsh Oh My Zsh 有上百個自帶的主題,我使用過的也就只有默認(rèn)主題 robbyrussell 還不錯。 也有很多第三方主題插件,使用人數(shù)最多,點(diǎn)評最好的是 Powerlevel10k,GitHub 已有 40K 的 Star,可見其受歡迎程度 Powerlevel10k 是一個終端美化主題插件,有著與 Oh My Zsh 搭配天作之合的美稱,可以將終端改造的更加美觀,炫酷 #### 2. 安裝 --- Powerlevel10k 倉庫:<https://github.com/romkatv/powerlevel10k> 安裝方式查看倉庫 README.md 文件,應(yīng)以 Github 倉庫中的安裝描述為準(zhǔn),本文使用其中一種 打開終端,運(yùn)行以下命令,從 Github 上克隆 Powerlevel10k 代碼庫,并將其放到 Oh My Zsh 的配置文件夾中 ``` git clone --depth=1 git@github.com:romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k ``` 編輯 `~/.zshrc` 文件,修改主題: ``` ZSH_THEME="powerlevel10k/powerlevel10k" ``` #### 3. 配置 --- ##### 第一步:安裝字體 重新打開終端窗口將看到以下配置向?qū)? ``` 這是 Powerlevel10k 配置向?qū)А?你看到它是因?yàn)槟銢]有定義任何 Powerlevel10k 配置選項(xiàng)。它會問你幾個問題提示進(jìn)行配置。 安裝 Meslo Nerd 字體? (y) 是 (推薦). (n) 否. 使用當(dāng)前字體 (q) 退出,什么也不做 ``` 鍵入 y 和 n 進(jìn)入下一步,鍵入 q 退出配置向?qū)?。此時將使用默認(rèn)配置,當(dāng)打開新窗口時會再次彈出配置向?qū)?  輸入 y 安裝推薦的字體,可能會出現(xiàn)以下提示,出現(xiàn)該提示時按下回車鍵結(jié)束向?qū)?,打開新窗口會重新提示配置向?qū)?  通過該網(wǎng)站獲取域名的正確 IP 地址:[www.ipaddress.com](https://sites.ipaddress.com/raw.githubusercontent.com) ,并將其配置到 hosts 文件中  ``` 185.199.108.133 raw.githubusercontent.com 185.199.109.133 raw.githubusercontent.com 185.199.110.133 raw.githubusercontent.com 185.199.111.133 raw.githubusercontent.com ``` 重新運(yùn)行配置向?qū)О惭b字體又出現(xiàn)了另外一個錯誤提示  這個錯誤的原因是因?yàn)榘惭b的源在國外,下載很慢,需要切換為國內(nèi)的源,運(yùn)行以下命令 ``` /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" ``` 我們只是切換為國內(nèi)的源,所以要輸入序號 6,然后輸入電腦的鎖屏密碼即可自動配置國內(nèi)源  打開新窗口重新運(yùn)行配置向?qū)?,可以發(fā)現(xiàn)推薦字體就能安裝成功了 ``` Meslo Nerd Font 字體已經(jīng)安裝成功 請重新啟動 iTerm2 使其更改生效 1. 點(diǎn)擊 iTerm2 退出或使用 ? + Q 退出 2. 打開 iTerm2 按照上面的說明重新啟動 iTerm2 非常重要。 僅僅關(guān)閉是不夠的 iTerm2,單擊紅色圓圈。您必須單擊 iTerm2 → 退出 iTerm2 或按 ? + Q。 ```  ##### 第二步:校驗(yàn)字體 校驗(yàn)字體是否正常安裝:鉆石圖案能正常展示說明推薦字體安裝成功了,輸入 y ``` # 這看起來像鉆石(旋轉(zhuǎn)的正方形)嗎? Does this look like a diamond (rotated square) ? ```  同上,下面的操作都是用來校驗(yàn)字體是否正常安裝的,都輸入 y 即可    ##### 第三步:主題風(fēng)格 Prompt Style 提示樣式【選擇 3】  Character Set 字符集【選擇 1】  Show current time 時間顯示格式【選擇 2】  Prompt Separators 分隔符樣式【選擇 2】  Prompt Heads 頭部樣式【選擇 1】  Prompt Tails 尾部樣式【選擇 2】  Prompt Height 提示高度。命令輸入在第 1 行還是第 2 行【選擇 2】  Prompt Connection 首尾連接方式 1 不連接 2 虛線 3 實(shí)線【選擇 2】  Prompt Frame 是否加 frame,選 1 首尾都不加 frame【選擇 1】  Connection Color 首尾連接線顏色【選擇 1】  Prompt Spacing 行間距。1 緊湊 2 稀疏【選擇 1】  Icons 圖標(biāo) 1 很少的圖標(biāo) 2 盡可能的展示圖標(biāo)【選擇 2】  Prompt Flow 命令耗時的顯示,1 concise 簡潔 2 Fluent 流利【選擇 1】  Enable Transient Prompt 是否只顯示瞬時的提示行,選 n 的話每次命令的提示都會保留【選擇 n】  Instant Prompt Mode 提示行模式,選 verbose【選擇 1】  是否更改 `~/.zshrc`【選擇 y】將在該文件末尾添加以下內(nèi)容 ``` # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh ```  最后的效果如下所示  #### 4. 命令 --- 再次配置 ```shell p10k configure ```