【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,搞定!

相关推荐
humors2212 天前
AI工具合集,不定期更新
人工智能·windows·ai·工具·powershell·deepseek
fengyehongWorld9 天前
Powershell 自动安装Excel自定义标签页,开启宏
powershell
西西弗Sisyphus11 天前
PowerShell 配置为启动时自动激活 Conda 环境
conda·powershell
夫唯不争,故无尤也25 天前
curl与Invoke-RestMethod核心区别
后端·fastapi·powershell·curl
bu_shuo1 个月前
Windows电脑使用VSCode远程控制Windows主机方法记录
windows·vscode·ssh·powershell
Moshow郑锴2 个月前
WindowsRemoteAdmin(超级马里奥像素版)专为无远程登录桌面系统打造的便携式管理工具
java·powershell·远程控制·远程桌面·系统运维
超级大福宝2 个月前
PowerShell 实现类似 Bash 的补全行为
bash·powershell
小雪_Snow2 个月前
PowerShell 版本升级教程
powershell
Whoami!2 个月前
⓫⁄₅ ⟦ OSCP ⬖ 研记 ⟧ Windows权限提升 ➱ 利用PowerShell获取敏感信息
网络安全·信息安全·powershell·windows日志