Files
hugo_blog.awin.one/content/posts/2022/用 oh-my-posh 美化 Git bash/index.md

48 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
slug: 用 oh-my-posh 美化 Git bash
title: 用 oh-my-posh 美化 Git bash
description:
toc: true
authors:
- awin
tags:
- terminal
categories:
- Tool setup
series:
- Windows
date: 2022-06-14T00:00:00
lastmod: 2022-06-14T00:00:00
featuredVideo:
featuredImage:
draft: false
enableComment: true
---
讓 [Windows Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701) 中的 Git bash 也可以美美的。
<!--more-->
## 步驟
以下步驟都是在 [Windows Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701) 中的 Git bash[^1] 執行。
1. 先下載一個你喜歡的theme: [https://ohmyposh.dev/docs/themes](https://ohmyposh.dev/docs/themes)
2. 下載並安裝字型:[Caskaydia Cove Nerd Font](https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/CascadiaCode.zip?WT.mc_id=-blog-scottha)
3. Install OhMyPosh: `winget install JanDeDobbeleer.OhMyPosh`
4. 建立並修改 `~/.profile`,然後加入
`eval "$(oh-my-posh --init --shell bash --config ~/montys.omp.json)"`
注意最後的 `montys.omp.json` 就是第一步下載的theme這邊要改成你自己的路徑。
5. 修改 Windows Terminal 的 `setting.json`,將字型改為 `CaskaydiaCove NF`
![](images/20220614221618_oh-my-posh_setting.png)
6. 重開 Windows Terminal
[^1]: 在 [Windows Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701) 中設定 Git bash 可以參考:[Windows Terminal's 設定 Git Bash 和 SSH @ 傑克! 真是太神奇了! :: 痞客邦 ::](https://magicjackting.pixnet.net/blog/post/225162505-windows-terminal's-%E8%A8%AD%E5%AE%9A-git-bash-%E5%92%8C-ssh)
## 成果
![20220614_221915_WindowsTerminal_1244x262.png](images/20220614_221915_WindowsTerminal_1244x262.png)
## 參考
- [Oh My Posh](https://ohmyposh.dev/)
- [How to make the ultimate Terminal Prompt on Windows 11 - This video is LONG and WORDY and DETAILED - YouTube](https://www.youtube.com/watch?v=VT2L1SXFq9U)
- [My Ultimate PowerShell prompt with Oh My Posh and the Windows Terminal - Scott Hanselman's Blog](https://www.hanselman.com/blog/my-ultimate-powershell-prompt-with-oh-my-posh-and-the-windows-terminal)
- [Windows-Terminal配置OhMyPosh来美化GitBash_偕臧x的博客-CSDN博客](https://blog.csdn.net/qq_33154343/article/details/120661945)