【shell】win10 Powershell字体美化

效果图如下:

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就可以换更多字体。

3安装Oh My Posh

bash 复制代码
winget install oh-my-posh

注意: windows update 要打开。如果离线安装还可能会用上"Add-AppxPackage"命令,还要打开win10自己可选功能有点麻烦,最好还是有微软商店,直接安装;如果好久没打开过更新,可能还要用DISM /Online /Cleanup-image /Restorehealth来修复

Add-AppxPackage:部署失败,原因是 0x80073CF3

本人由于系统老旧,在这个问题上困扰了好久一直没装winget、也装不回来微软商店...

4下载主题文件

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

5配置主题文件进Powershell

bash 复制代码
notepad $Profile

填入

bash 复制代码
oh-my-posh --init --shell pwsh --config "替换为你自己存放主题的目录\M365Princess.omp.json" | Invoke-Expression

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

重启Powershell,搞定!

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

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

找到git的配置文件,路径如下

bash 复制代码
C:\Program Files\Git\etc\bash.bashrc

最后一行添加以下代码

bash 复制代码
eval "$(oh-my-posh --init --shell bash --config '替换为你自己存放主题的目录\M365Princess.omp.json')"

重启Git bash,搞定!

相关推荐
bosins4 天前
Windows IIS 配置本地HTTPS 全流程指南:自签名证书 + 端口绑定 + 避坑详解
powershell·openssl
DogDaoDao15 天前
Windows 开发提效工具全景指南:60+ 工具的工程化分层配置
windows·git·程序员·开发工具·powershell·everything·msys2
winfredzhang1 个月前
用 wxPython 打造「Claude Code 任务启动器」:一个把 AI CLI 变成一键工作流的桌面工具
python·wxpython·powershell·剪贴板·claudecodecli
鬼手点金1 个月前
Hermes‑Agent 使用教程
python·ubuntu·powershell·cmd·ai agent·opencode·hermes
寒水馨1 个月前
macOS下载、安装PowerShell-v7.6.4(附安装包powershell-7.6.4-osx-arm64.pkg)
macos·自动化·跨平台·shell·脚本·命令行·powershell
寒水馨1 个月前
Linux下载、安装PowerShell-v7.6.4(附安装包powershell-7.6.4-linux-x64.tar.gz)
linux·跨平台·自动化运维·devops·命令行·powershell·脚本语言
儒雅的烤地瓜2 个月前
计算机网络 | 网络诊断双刃剑:Tracert路由追踪实战与Windows防火墙端口配置指南
tcp/ip·计算机网络·wireshark·防火墙·powershell·cmd
vortex52 个月前
PowerShell Provider 机制详解:从文件系统到注册表的统一抽象
windows·powershell
无为之士3 个月前
Windows 批量打印 PDF 工具分享:支持文件夹、指定文件、当天文件、预览列表
windows·powershell
阆遤3 个月前
Windows环境安装Hermes Desktop安装
powershell·ai agent·hermes desktop