> For the complete documentation index, see [llms.txt](https://jacky-chen.gitbook.io/jackychen/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jacky-chen.gitbook.io/jackychen/others/zsh-command-line.md).

# zsh command line

## 套用 nerd.terminal 設定

* 先下載 nerd.terminal&#x20;
* 打開 terminal.app -> 終端機 -> 偏好設定
* 點左下角齒輪 -> 匯入 nerd.terminal
* 將 nerd 設定為預設值

{% file src="/files/-MGX41tkydnjPbsZJhPN" %}

## 安裝 zsh

用 homebrew 安裝

```
brew install zsh
```

並把 zsh 設定為你的預設 shell

```bash
sudo sh -c "echo $(which zsh) >> /etc/shells" 
chsh -s $(which zsh)
```

安裝 on-my-zsh

```bash
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
```

### **安裝 zsh theme** [**powerlevel9k**](https://github.com/bhilburn/powerlevel9k) <a href="#id-38ce" id="id-38ce"></a>

```bash
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
```

### 編輯 `~/.zshrc`

```bash
ZSH_THEME="powerlevel9k/powerlevel9k"

# command line 左邊想顯示的內容
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir dir_writable vcs) # <= left prompt 設了 "dir vcs"

# command line 右邊想顯示的內容
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status time) # <= right prompt 設了 "status time"

POWERLEVEL9K_MODE='nerdfont-complete'
```

### 安裝 sourcecodepro-nerd-font 字型

{% hint style="warning" %}
字型檔已無法透過 Homebrew 下載，必須手動處理
{% endhint %}

* [下載字型檔](https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/SourceCodePro.zip)
* 解壓縮
* 打開 Spotlight，搜尋**字體簿**
* &#x9EDE;**＋**&#x532F;入字型檔
* 打開 terminal.app -> 終端機 -> 偏好設定
* 選 nerd -> 字體 ->更改，選 Source Code Pro Nerd Font Complete&#x20;

{% hint style="info" %}

### 參考連結

[超簡單！十分鐘打造漂亮又好用的 zsh command line 環境](https://medium.com/statementdog-engineering/prettify-your-zsh-command-line-prompt-3ca2acc967f)

[zsh + oh-my-zsh](https://medium.com/@prinswu/zsh-oh-my-zsh-powerlevel9k-in-2020-macbook-pro-13-c85f6a409bee)
{% endhint %}
