> 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 %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://jacky-chen.gitbook.io/jackychen/others/zsh-command-line.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
