【PW】win10 Powershell字体美化
2026/8/5 13:26:37 网站建设 项目流程

效果图如下:
powershell 7方案

git bash方案

1升级安装 PowerShell 7

下载地址:https://github.com/PowerShell/PowerShell/releases
win10 1809装不了Windows terminal 本人试过了提示不兼容

其他:git bash方案的话下载安装git即可

2安装字体NerdFonts

下载地址:https://gith
ub.com/romkatv/dotfiles-public/tree/master/.local/share/fonts/NerdFonts
💡Tips: 除了NerdFonts,还有很多程序员爱用的字体,例如JetBrainsMonoNerdFont-Regular,但是win10 PowerShell 7似乎只能识别NerdFonts字体,其他字体没试成功;如果用Windows terminal就可以换更多字体。

如果是vscode使用需要设置字体:

3安装Oh My Posh

wingetinstalloh-my-posh

注意: windows update 要打开。如果离线安装还可能会用上“Add-AppxPackage”命令,还要打开win10自己可选功能有点麻烦,最好还是有微软商店,直接安装;如果好久没打开过更新,可能还要用DISM /Online /Cleanup-image /Restorehealth来修复
Add-AppxPackage:部署失败,原因是 0x80073CF3
本人由于系统老旧,在这个问题上困扰了好久一直没装winget、也装不回来微软商店…

4下载主题文件

下载地址:https://ohmyposh.dev/docs/themes

5配置主题文件进Powershell

notepad$Profile

填入

oh-my-posh--init--shellpwsh--config"替换为你自己存放主题的目录\M365Princess.omp.json"|Invoke-Expression"C:\Users\Administrator\AppData\Local\Programs\oh-my-posh\themes\catppuccin_latte.omp.json"

M365Princess.omp.json 这是我的主题文件

重启Powershell,搞定!
附:网上也有其他环境配置环境变量$env:POSH_THEMES_PATH/、用命令Get-PoshThemes来查主题,个人觉得没必要就不折腾了。

但很多皮肤对vscode的pw不友好

就是莫名其妙的或缩进,输入的位置多了几个空格,很不习惯,但是在vscode外面的pw又是正常的,下面做个笔记,为数不多显示正常的皮肤——比原版有颜色标记就行。
“emodipt-extend.omp.json”

6方案2-配置主题文件进git bash

找到git的配置文件,记事本打开路径如下

notepad"C:\Program Files\Git\etc\bash.bashrc"

最后一行添加以下代码

eval"$(oh-my-posh--init--shellbash--config'替换为你自己存放主题的目录\M365Princess.omp.json')""C:\Users\Administrator\AppData\Local\Programs\oh-my-posh\themes\catppuccin_latte.omp.json"

重启Git bash,搞定!

其他可以自己修改主题文件

最后,自己可以在主题文件里面找到主题文件,复制代码给 GPT,让他帮忙按自己的想法改一下。比如说现在这个,我让他把虚拟环境(如果有的话)也显示出来。

{"$schema":"https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json","blocks":[{"alignment":"left","newline":true,"segments":[{"foreground":"#E5C07B","options":{"time_format":"15:04"},"style":"plain","template":"[{{ .CurrentDate | date .Format }}]","type":"time"},{"type":"shell","style":"plain","foreground":"#E06C75","options":{"mapped_shell_names":{"pwsh":"Shell","powershell":"Shell","cmd":"Cmd","bash":"Bash"}},"template":" \ue795 {{ .Name }}"},{"type":"python","style":"plain","foreground":"#98C379","template":" ({{ .Venv }})"},{"type":"executiontime","style":"plain","foreground":"#b8ff75","foreground_templates":["{{ if gt .Code 0 }}#E06C75{{ end }}"],"template":" {{ .FormattedMs }}","properties":{"threshold":500}},{"foreground":"#F3C267","foreground_templates":["{{ if or (.Working.Changed) (.Staging.Changed) }}#FF9248{{ end }}","{{ if and (gt .Ahead 0) (gt .Behind 0) }}#ff4500{{ end }}","{{ if gt .Ahead 0 }}#B388FF{{ end }}","{{ if gt .Behind 0 }}#B388FF{{ end }}"],"options":{"branch_template":"{{ trunc 25 .Branch }}","fetch_status":true,"fetch_upstream_icon":true},"style":"plain","template":" {{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} \ueb4b {{ .StashCount }}{{ end }} ","type":"git"}],"type":"prompt"},{"alignment":"right","segments":[{"type":"status","style":"plain","foreground":"#b8ff75","foreground_templates":["{{ if gt .Code 0 }}#E06C75{{ end }}"],"template":" x{{ reason .Code }}"}],"type":"prompt"},{"alignment":"left","newline":true,"segments":[{"foreground":"#61AFEF","options":{"style":"full"},"style":"plain","template":"\ue5ff {{ .Path }}","type":"path"}],"type":"prompt"},{"alignment":"left","newline":true,"segments":[{"foreground":"#E06C75","style":"plain","template":"\u0021","type":"root"},{"foreground":"#E06C75","style":"plain","template":"\u276f","type":"text"}],"type":"prompt"}],"final_space":true,"version":4}

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询