windows使用oh-my-posh美化powershell命令提示符

  需要提前安装的软件:windows terminal、git。

  1. 安装oh-my-posh,需要保证git命令可用,这里默认git已经安装好,之后用下面命令安装oh-my-posh:
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser

  如果安装过程oh-my-posh无法下载下来,则采取手动下载,添加 -Verbose 来显示安装过程的log

Install-Module oh-my-posh -Scope CurrentUser -Verbose

  然后观察下面的输出,找到要安装的 oh-my-posh 的下载地址,例如我现在安装的就是3.164.0版本的,地址是

https://www.powershellgallery.com/api/v2/package/oh-my-posh/3.164.0

  然后直接浏览器下载即可,下载的文件是 .nupkg 格式的,修改后缀为 .zip 解压。然后将解压后的文件夹放到 powershell 的 modules 文件夹下,比如说,我这里要为powershell7安装oh-my-posh,由于这里是对当前用户安装的,powershell的实际安装路径是这个:

C:\Users\name\Documents\WindowsPowerShell
(如果对所有用户安装需要找到powershell的系统目录,一般是C:\Program Files\WindowsPowerShell)

  解压的文件夹放置的路径就为:

C:\Users\name\Documents\WindowsPowerShell\Modules\oh-my-posh\3.164.0
(注意一定是 \Modules\模块名\模块的版本号)。

  之后输入下面的命令可以看到oh-my-posh安装完毕。

Import-Module posh-git
Import-Module oh-my-posh
module
  1. 在profile文件中写入下面内容即可启用oh-my-posh主题
Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt Paradox //paradox为主题名称
  1. 下载Nerd Fonts字体

  通过上面的步骤启用oh-my-posh后会有很多乱码,很难看,因为没有安装专用的字体。许多网上教程是让用下面的方式下载powerline字体,但是powerline字体是不适用于oh-my-posh的。

# 下载
git clone https://github.com/powerline/fonts.git --depth=1
# 安装
cd fonts
./install.ps1
# 安装完毕删除 fonts 文件夹即可

  用上面的方法下载字体并设置使用对应的字体后乱码有所改善,但是任然有部分乱码,并且无论切换什么powerline字体都无法继续改善,如下图:

  通过查看oh-my-posh的官方文档得知oh-my-posh是使用Nerd Fonts进行设计的,文档地址如下:

https://ohmyposh.dev/docs/fonts

  文档中给出了Nerd Fonts的下载链接,但是好像需要翻墙才能打开,链接地址如下:

https://www.nerdfonts.com/

  这里下载了字体SourceCodePro,并在windows terminal的settings.json中设置使用该字体,即设置"fontFace": “SauceCodePro Nerd Font”,下面为windows terminal的配置文档。

{"$schema": "https://aka.ms/terminal-profiles-schema",// Add custom actions and keybindings to this array.// To unbind a key combination from your defaults.json, set the command to "unbound".// To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings"actions": [// Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.// These two lines additionally bind them to Ctrl+C and Ctrl+V.// To learn more about selection, visit https://aka.ms/terminal-selection{"command": {"action": "copy","singleLine": false},"keys": "ctrl+c"},{"command": "paste","keys": "ctrl+v"},// Press Ctrl+Shift+F to open the search box{"command": "find","keys": "ctrl+shift+f"},// Press Alt+Shift+D to open a new pane.// - "split": "auto" makes this pane open in the direction that provides the most surface area.// - "splitMode": "duplicate" makes the new pane use the focused pane's profile.// To learn more about panes, visit https://aka.ms/terminal-panes{"command": {"action": "splitPane","split": "auto","splitMode": "duplicate"},"keys": "alt+shift+d"}],"copyFormatting": "none","copyOnSelect": false,"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}","profiles": {"defaults": {//适用所有配置文件的设置"startingDirectory": "%USERPROFILE%", //起始目录//"icon": "C:\\Users\\DustinWinFiles\\Pictures\\Java.png", // 图标,建议每一类在list中单独设置//"tabTitle": "XXX", //自定义选项卡标题,设置了所有的tab页都会是这个名字"suppressApplicationTitle": true, //禁止shell更改标题"fontFace": "Fira Code", //字体"fontSize": 12, //字体大小"fontWeight": "normal", // 字体粗细"padding": "8, 8, 8, 8", // 填充(内容距离界面的内部距离)"antialiasingMode": "cleartype", // 消除文本锯齿"cursorShape": "vintage", // 光标形状"cursorColor": "#11EE11", // 光标颜色"cursorHeight": 100, // 光标高度("cursorShape"设置为"vintage"时可用)"altGrAliasing": true, // AltGr别名//"colorScheme": "Ubuntu", // 配色方案  在单个中定义"colorScheme": "One Half Dark", // 配色方案//"selectionBackground": "#0000e6", //所选内容的背景色(选用"colorScheme"内的)"useAcrylic": true, //启用 acrylic(亚克力特效)"acrylicOpacity": 0.7, //Acrylic 不透明度//"backgroundImage": "C:\\Users\\DustinWinFiles\\Pictures\\colorful.jpg", //背景图像设置//"backgroundImageStretchMode": "uniformToFill", // 背景图像拉伸模式// "backgroundImageAlignment": "center", //背景图像对齐//"backgroundImageOpacity": 0.5, //背景图像不透明度"scrollbarState": "visible", //滚动条可见性"snapOnInput": true, //键入时滚动到输入行"historySize": 9001, //历史记录大小"closeOnExit": "graceful", //退出时配置文件的关闭方式(输入exit退出命令窗口)//"experimental.retroTerminalEffect": false // 怀旧式终端效果"alwaysOnTop": true, //始终处于顶部模式},"list": [{"commandline": "powershell.exe",//"fontFace": "DejaVu Sans Mono for Powerline","fontFace": "SauceCodePro Nerd Font", //设置使用Nerd Fonts"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}","hidden": false,"colorScheme": "Solarized Darcula","name": "Windows PowerShell"},{"commandline": "cmd.exe","guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}","hidden": false,"name": "Command Prompt"},{"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}","hidden": false,"name": "Azure Cloud Shell","source": "Windows.Terminal.Azure"},{"fontFace": "SauceCodePro Nerd Font","guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}","hidden": false,"name": "PowerShell","source": "Windows.Terminal.PowershellCore"}]},"schemes": [{"name": "Solarized Dark","black": "#002831","red": "#d11c24","green": "#738a05","yellow": "#a57706","blue": "#2176c7","purple": "#c61c6f","cyan": "#259286","white": "#eae3cb","brightBlack": "#475b62","brightRed": "#bd3613","brightGreen": "#475b62","brightYellow": "#536870","brightBlue": "#708284","brightPurple": "#5956ba","brightCyan": "#819090","brightWhite": "#fcf4dc","background": "#001e27","foreground": "#708284"},{"name": "One Half Dark","black": "#2e3436","red": "#cc0000","green": "#4e9a06","yellow": "#c4a000","blue": "#3465a4","purple": "#75507b","cyan": "#06989a","white": "#d3d7cf","brightBlack": "#555753","brightRed": "#ef2929","brightGreen": "#8ae234","brightYellow": "#fce94f","brightBlue": "#729fcf","brightPurple": "#ad7fa8","brightCyan": "#34e2e2","brightWhite": "#eeeeec","background": "#300a24", //背景色"foreground": "#eeeeec", //前景色},{"name": "Solarized Darcula","black": "#25292a","red": "#f24840","green": "#629655","yellow": "#b68800","blue": "#2075c7","purple": "#797fd4","cyan": "#15968d","white": "#d2d8d9","brightBlack": "#25292a","brightRed": "#f24840","brightGreen": "#629655","brightYellow": "#b68800","brightBlue": "#2075c7","brightPurple": "#797fd4","brightCyan": "#15968d","brightWhite": "#d2d8d9","background": "#3d3f41","foreground": "#d2d8d9"},  {"background": "#0C0C0C","black": "#0C0C0C","blue": "#0037DA","brightBlack": "#767676","brightBlue": "#3B78FF","brightCyan": "#61D6D6","brightGreen": "#16C60C","brightPurple": "#B4009E","brightRed": "#E74856","brightWhite": "#F2F2F2","brightYellow": "#F9F1A5","cursorColor": "#FFFFFF","cyan": "#3A96DD","foreground": "#CCCCCC","green": "#13A10E","name": "Campbell","purple": "#881798","red": "#C50F1F","selectionBackground": "#FFFFFF","white": "#CCCCCC","yellow": "#C19C00"},{"background": "#012456","black": "#0C0C0C","blue": "#0037DA","brightBlack": "#767676","brightBlue": "#3B78FF","brightCyan": "#61D6D6","brightGreen": "#16C60C","brightPurple": "#B4009E","brightRed": "#E74856","brightWhite": "#F2F2F2","brightYellow": "#F9F1A5","cursorColor": "#FFFFFF","cyan": "#3A96DD","foreground": "#CCCCCC","green": "#13A10E","name": "Campbell Powershell","purple": "#881798","red": "#C50F1F","selectionBackground": "#FFFFFF","white": "#CCCCCC","yellow": "#C19C00"},{"background": "#282C34","black": "#282C34","blue": "#61AFEF","brightBlack": "#5A6374","brightBlue": "#61AFEF","brightCyan": "#56B6C2","brightGreen": "#98C379","brightPurple": "#C678DD","brightRed": "#E06C75","brightWhite": "#DCDFE4","brightYellow": "#E5C07B","cursorColor": "#FFFFFF","cyan": "#56B6C2","foreground": "#DCDFE4","green": "#98C379","name": "One Half Dark","purple": "#C678DD","red": "#E06C75","selectionBackground": "#FFFFFF","white": "#DCDFE4","yellow": "#E5C07B"},{"background": "#FAFAFA","black": "#383A42","blue": "#0184BC","brightBlack": "#4F525D","brightBlue": "#61AFEF","brightCyan": "#56B5C1","brightGreen": "#98C379","brightPurple": "#C577DD","brightRed": "#DF6C75","brightWhite": "#FFFFFF","brightYellow": "#E4C07A","cursorColor": "#4F525D","cyan": "#0997B3","foreground": "#383A42","green": "#50A14F","name": "One Half Light","purple": "#A626A4","red": "#E45649","selectionBackground": "#FFFFFF","white": "#FAFAFA","yellow": "#C18301"},{"background": "#002B36","black": "#002B36","blue": "#268BD2","brightBlack": "#073642","brightBlue": "#839496","brightCyan": "#93A1A1","brightGreen": "#586E75","brightPurple": "#6C71C4","brightRed": "#CB4B16","brightWhite": "#FDF6E3","brightYellow": "#657B83","cursorColor": "#FFFFFF","cyan": "#2AA198","foreground": "#839496","green": "#859900","name": "Solarized Dark","purple": "#D33682","red": "#DC322F","selectionBackground": "#FFFFFF","white": "#EEE8D5","yellow": "#B58900"},{"background": "#FDF6E3","black": "#002B36","blue": "#268BD2","brightBlack": "#073642","brightBlue": "#839496","brightCyan": "#93A1A1","brightGreen": "#586E75","brightPurple": "#6C71C4","brightRed": "#CB4B16","brightWhite": "#FDF6E3","brightYellow": "#657B83","cursorColor": "#002B36","cyan": "#2AA198","foreground": "#657B83","green": "#859900","name": "Solarized Light","purple": "#D33682","red": "#DC322F","selectionBackground": "#FFFFFF","white": "#EEE8D5","yellow": "#B58900"},{"background": "#000000","black": "#000000","blue": "#3465A4","brightBlack": "#555753","brightBlue": "#729FCF","brightCyan": "#34E2E2","brightGreen": "#8AE234","brightPurple": "#AD7FA8","brightRed": "#EF2929","brightWhite": "#EEEEEC","brightYellow": "#FCE94F","cursorColor": "#FFFFFF","cyan": "#06989A","foreground": "#D3D7CF","green": "#4E9A06","name": "Tango Dark","purple": "#75507B","red": "#CC0000","selectionBackground": "#FFFFFF","white": "#D3D7CF","yellow": "#C4A000"},{"background": "#FFFFFF","black": "#000000","blue": "#3465A4","brightBlack": "#555753","brightBlue": "#729FCF","brightCyan": "#34E2E2","brightGreen": "#8AE234","brightPurple": "#AD7FA8","brightRed": "#EF2929","brightWhite": "#EEEEEC","brightYellow": "#FCE94F","cursorColor": "#000000","cyan": "#06989A","foreground": "#555753","green": "#4E9A06","name": "Tango Light","purple": "#75507B","red": "#CC0000","selectionBackground": "#FFFFFF","white": "#D3D7CF","yellow": "#C4A000"},{"background": "#000000","black": "#000000","blue": "#000080","brightBlack": "#808080","brightBlue": "#0000FF","brightCyan": "#00FFFF","brightGreen": "#00FF00","brightPurple": "#FF00FF","brightRed": "#FF0000","brightWhite": "#FFFFFF","brightYellow": "#FFFF00","cursorColor": "#FFFFFF","cyan": "#008080","foreground": "#C0C0C0","green": "#008000","name": "Vintage","purple": "#800080","red": "#800000","selectionBackground": "#FFFFFF","white": "#C0C0C0","yellow": "#808000"}]
}

  设置完成后字符显示正常,效果如下:

windows使用oh-my-posh美化powershell命令提示符相关推荐

  1. 使用Oh my posh美化Windows终端(一)

    这篇文章介绍一下 Windows 终端的美化. 介绍 Windows 终端 以下引用微软官网的介绍: Windows 终端是一个新式主机应用程序,它面向你喜爱的命令行 shell,如命令提示符.Pow ...

  2. Windows 终端美化 PowerShell 默认终端修改

    Windows 终端美化 PowerShell 默认终端修改 安装 oh-my-posh 安装Powerline字体 安装ConEmu 美化powershell 设置ConEmu 把界面默认语言改为中 ...

  3. Windows Terminal 美化 / PowerShell 美化: oh-my-posh 主题安装和使用

    关键词: nerd-font; oh-my-posh; posh; powerline-font; powershell; scoop; winget 最终效果预览 说明事项 本文与网络上多数介绍 o ...

  4. Neo4j安装事项报错:powershell命令提示符出现“不是内部或外部命令,也不是可运行的程序或批处理文件

    这些天因为老板需求,捣鼓下Neo4j,在win7上按照网上的教程安装,顺风顺水:但是在服务器上(winServer2012R2)安装却是报错:powershell命令提示符出现"不是内部或外 ...

  5. Windows 任务计划程序定时执行 powershell 脚本

    由于需要进行一些特殊操作,打算使用 powershell 来写脚本,需要Windows 任务计划程序定时执行. 怎么在Windows 任务计划程序中执行powershell脚本?? 做一个简单测试:本 ...

  6. powershell快捷键_借助Windows Terminal搞一个花里胡哨的PowerShell终端

    一提起PowerShell,命令提示符等等,想到的就是丑.难用,非常丑! 各位可以先感受一下. 不过,现在我们可以对它做一个美化,美化后的效果如下,各位也可以感受下(本人不提供背景图) 下面做简单记录 ...

  7. Windows 10下,如何使用PowerShell批量重启局域网电脑

    PowerShell 在Windows 10中越来越受到微软重视,甚至被微软安排在开始按钮超级菜单中替换了一直以来默认的命令提示符(当然还可以换回去),这和该工具越来越强大密不可分.这次就介绍一个&q ...

  8. windows服务器远程执行命令(PowerShell+WinRM)

    Windows 远程管理 (WinRM) 是 WS-Management 协议的 Microsoft 实现.该协议是基于简单对象访问协议 (SOAP) 的.防火墙友好的标准协议,使来自不同供应商的硬件 ...

  9. win10美化PowerShell

    1.安装ConEmu(windows终端增强版) choco install ConEmu choco命令安装参见 2.安装PowerShell字体 git clone https://github. ...

最新文章

  1. 如何查看python是多少位的-请问一下该怎么查看python是32位还是64位?
  2. 再见 2020!Apache RocketMQ 发布 4.8.0,DLedger 模式全面提升!
  3. Hibernate 一对一注释
  4. 树的直径(51Nod-2602)
  5. Dropbox 官方中文版!最优秀实用的免费跨平台文件网络同步网盘云存储服务
  6. ubuntu网络设置找不到有线连接_win7系统找不到网络打印机如何解决?局域网打印机共享怎么设置?...
  7. 微PE工具箱四合一下载并安装
  8. 编译UE4出现C1076错误的解决方法
  9. win10计算机管理器端口号,Win10设备管理器没有端口选项的解决方法
  10. 利用MC34063升压180V的心(辛)路(酸)历(经)程(历)
  11. ISIS TLV Cyrus
  12. 19年11月最新Win10 LTSC系统封装部署教程(超详细)
  13. Tushare介绍和入门级实践(1)——使用tushare接口获取沪深300成分股交易日涨跌数据
  14. android中可左右滑动输入框
  15. kubernetes使用flannel网络插件服务状态显示CrashLoopBackOff
  16. citra黑屏_3ds模拟器最新版Citra下载_3ds模拟器Citra2019最新版下载_游戏堡
  17. android友盟统计按钮点击次数,友盟统计按钮点击事件
  18. 从游戏中理解Java特性,我悟了!
  19. Android牌子p40pro的手机,华为P40Pro手机使用深度对比实用评测
  20. 艺体计算机教师考核细则,艺体教师考核细则.docx

热门文章

  1. 读万卷书不如行万里路,行万里路不如阅人无数,阅人无数不如名师指路
  2. 用弦截法求解方程的根
  3. 如何查看网站服务器到期时间吗,如何查看云服务器到期时间
  4. nginx -s reload命令
  5. QQ显IP绝迹江湖了吗?
  6. 数据结构-树 速通指南
  7. 网易会议开源之桌面端篇
  8. 假若重新度过大学四年。。
  9. 2014年12月30日,31日,2015年1月3日,4日
  10. Docker基础与进阶梳理(干货满满)