> For the complete documentation index, see [llms.txt](https://docs.xiwind-corp.com/tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xiwind-corp.com/tech/git/windows-terminalpowershell-an-zhuang.md).

# Windows Terminal、PowerShell 安裝

在今天的數位時代，對於開發人員、系統管理員和高級使用者來說，擁有一個強大命令列工具是必不可少的。Windows Terminal 和 PowerShell 7 在 Windows 10 提供了增強的 Command line。我們將為您介紹安裝 Windows Terminal 和 PowerShell 7 的步驟，讓您充分利用它們的功能並提高生產力。讓我們開始吧！

## Windows Terminal

***

Windows Terminal 是 Windows 10 的新的現代命令行 (Command line) 應用程序， 它的目的是在為開發人員和 IT 專業人員提供更高效的命令行經驗。

預設的命令提示字元 (CMD; Command Prompt) 是多年來 Windows 操作系統的一部分的基本命令行工具。 與 Windows Terminal 相比，CMD只有有限的功能和自定義選項。 另一方面，Windows Terminal 提供了更高級的功能，例如多個選項卡，自定義選項以及對 PowerShell，命令提示和 WSL 等各種的 shell 支援。 使用 Windows Terminal，您可以為您的命令行任務具有更簡化，更有效的工作流程。

1. **下載並安裝** [**Windows Terminal**](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=zh-tw\&gl=tw)。

<div><figure><img src="/files/qbsZoU1q1JYmOMLluWGD" alt="" width="375"><figcaption><p>Windows Terminal</p></figcaption></figure> <figure><img src="/files/4CuFkk82QS5taA94En0L" alt="" width="375"><figcaption><p>原始CMD</p></figcaption></figure></div>

## PowerShell 7

***

PowerShell 7 是 Microsoft 最新發布的 Command-Line Interface 版本。它相對於其前身 Windows 預設的 PowerShell (PowerShell 5.1) 帶來了多項改進。例如：跨平台、改進的性能、對其他數據類型的支持以及新的語言功能。 PowerShell 7 還具有更現代、更靈活的架構，使其能夠用於各種場景，包括自動化、配置管理和 DevOps。

1. **下載並安裝**[**PowerShell 7**](https://github.com/PowerShell/PowerShell/releases) **。**

<div><figure><img src="/files/cy4ZxWtWrzvUXNegRGSz" alt="選擇安裝的版本" width="375"><figcaption><p>選擇安裝的版本</p></figcaption></figure> <figure><img src="/files/Ks70AANxEl2gfxQPpweZ" alt="安裝畫面" width="310"><figcaption><p>安裝畫面</p></figcaption></figure></div>

<div><figure><img src="/files/WZHLGQgzdhvV0XeKgsck" alt="" width="375"><figcaption><p>PowerShell 7 畫面</p></figcaption></figure> <figure><img src="/files/iHNYUK2ni1GM0mIHnxOz" alt="" width="358"><figcaption><p>PowerShell 5.1 畫面</p></figcaption></figure></div>

### Oh My Posh

***

1. **在PowerShell 7安裝。** ([Oh My Posh](https://ohmyposh.dev/docs/installation/windows))

{% code title="SHELL" %}

```powershell
winget install JanDeDobbeleer.OhMyPosh -s winget
```

{% endcode %}

2. **重新啟動 PowerShell 7。**
3. **設定 Oh My Posh和主題**：[主題列表](https://ohmyposh.dev/docs/themes)

{% code title="SHELL" %}

```powershell
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/jblab_2021.omp.json" | Invoke-Expression
```

{% endcode %}

4. [**下載**](https://www.nerdfonts.com/#cheat-sheet)**和安裝字體**。(例如: [Meslo LGM NF](https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.2/Meslo.zip)， `MesloLGMNerdFontMono-Regular.ttf`)

<div><figure><img src="/files/qGZS7o3MYzNLDxOOxbdF" alt="1. 選擇喜歡的字體" width="375"><figcaption><p>1. 選擇喜歡的字體</p></figcaption></figure> <figure><img src="/files/dTHRv4Lbm5RVDL9g0kVL" alt="2. 打開設定"><figcaption><p>2. 打開設定</p></figcaption></figure></div>

<div><figure><img src="/files/8XiVQ0J58wPiergJ0rGA" alt="3. 預設值、外觀"><figcaption><p>3. 預設值、外觀</p></figcaption></figure> <figure><img src="/files/tq8dpAKbUYXOR8VVQR0b" alt="3. 字體、修改字體"><figcaption><p>3. 字體、修改字體</p></figcaption></figure></div>

5. **進入 Oh My Posh，檢查字體。**

{% code title="SHELL" %}

```powershell
oh-my-posh init pwsh | Invoke-Expression
```

{% endcode %}

!\[\[Pasted image 20230308094003.png#center|字體已經正常顯示|400]]

<figure><img src="/files/9F2cXPwT16xTTLKbDOiH" alt="字體已經正常顯示" width="375"><figcaption><p>字體已經正常顯示</p></figcaption></figure>

6. **使用命令，建立 Oh My Posh 設定的檔案。** 路徑為 `C:\Users\<Users>\Documents\PowerShell\Microsoft.PowerShell_profile.ps1`

{% code title="SHELL" %}

```powershell
New-Item -Path $profile -ItemType "file" -Force
```

{% endcode %}

!\[\[Pasted image 20230502000551.png|400]]

<figure><img src="/files/a8V1jnvePPuskTPK6ena" alt="" width="375"><figcaption></figcaption></figure>

7. **打開`Microsoft.PowerShell_profile.ps1`，設定主題和自動進入 Oh My Posh。**

{% code title="SHELL" %}

```powershell
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/jblab_2021.omp.json" | Invoke-Expression
```

{% endcode %}

!\[\[Pasted image 20230223014407.png#inl|在.ps1檔案中，加入命令|300]] !\[\[Pasted image 20230308094103.png#inl|重開Windows Terminal|350]]

<figure><img src="/files/NzOGqtR6aLKQ3bLbPuxx" alt="" width="375"><figcaption></figcaption></figure>

8. **可以使用以下命令預覽主題。**

{% code title="SHELL" %}

```powershell
Get-PoshThemes
```

{% endcode %}

{% hint style="info" %}
**Visual Studio Code 設定。**

打開設定，並輸入`Integrated:Font Family`和`MesloLGM NF`
{% endhint %}

## 自定義 Windows Terminal

***

Windows Terminal 提供各種自定義選項來個人化您的 Command line。以下是一些幫助您入門的自定義設定：

1. **預設啟動和大小。**

<div><figure><img src="/files/ZZJR1muOvEW55uzFszE2" alt="" width="375"><figcaption><p>可以同時關閉多個終端</p></figcaption></figure> <figure><img src="/files/bPbPhCvWtvYRSJ2WWlnu" alt="" width="375"><figcaption><p>調整啟動、大小</p></figcaption></figure></div>

2. **加入背景圖片。** ([範例圖片](https://drive.google.com/file/d/1FhGK4j3bin0q85KeosOaIXlaNl-wJXL0/view?usp=sharing))

<div><figure><img src="/files/GtzqHhcjI631oF7r79Uv" alt="" width="375"><figcaption><p>預設值 ->外觀</p></figcaption></figure> <figure><img src="/files/afVSUc6z086vOgqB1wF2" alt="" width="375"><figcaption><p>調整背景</p></figcaption></figure></div>

4. **釘選到開始和工作列。**

<div><figure><img src="/files/SFj9VV6JLkHeTOJD852I" alt="釘選到開始" width="269"><figcaption><p>釘選到開始</p></figcaption></figure> <figure><img src="/files/1VaRlNBN87N2X4KFOhZR" alt="釘選到工作列" width="218"><figcaption><p>釘選到工作列</p></figcaption></figure></div>

## 結論

***

恭喜！您已成功安裝了 Windows Terminal、PowerShell 7 和 Oh My Posh。使用 Windows Terminal，您可以享受現代化且多功能的 Terminal；而 PowerShell 7 則提供跨平台 Scripting 撰寫體驗。Oh My Posh 可增強 CLI 的提示。透過遵循這些安裝步驟，您已邁出最佳化 Command-line workflow 的第一步。掌握這些強大工具並探索其高級功能以提高生產力和 Command-line 體驗。

## 參考資料

***

[Windows 終端機自訂提示設定 | Microsoft Learn](https://learn.microsoft.com/zh-tw/windows/terminal/tutorials/custom-prompt-setup)

[Windows | Oh My Posh](https://ohmyposh.dev/docs/installation/windows)

[Releases · PowerShell/PowerShell](https://github.com/PowerShell/PowerShell/releases)

[PowerShell 7 - 來安裝最新版的 pwsh | 成功他媽．阿瑋](https://www.kwchang0831.dev/dev-env/pwsh)

[安裝新版 Oh My Posh 與插件來美化 PowerShell | 成功他媽．阿瑋](https://www.kwchang0831.dev/dev-env/pwsh/oh-my-posh)

[Top 10 Best Ubuntu Terminal Themes and Color Schemes](https://www.ubuntupit.com/best-ubuntu-terminal-themes-and-color-schemes/)

[Fonts | Oh My Posh](https://ohmyposh.dev/docs/installation/fonts)

[使用 Oh My Posh 美化 Windows 指令視窗 外觀設定](https://www.ruyut.com/2022/06/windows-oh-my-posh.html)

[Powershell 美化作戰 —— 字型、執行原則和 oh-my-posh | 伊果的沒人看筆記本](https://igouist.github.io/post/2020/08/powershell-beauty/)

[Windows 終端機自訂提示設定 | Microsoft Learn](https://learn.microsoft.com/zh-tw/windows/terminal/tutorials/custom-prompt-setup)


---

# 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:

```
GET https://docs.xiwind-corp.com/tech/git/windows-terminalpowershell-an-zhuang.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
