WindowsCMD窗口配置OhMyPosh

WindowsCMD窗口配置OhMyPosh

文章目录

  • WindowsCMD窗口配置OhMyPosh
  • [1. 按装Clink](#1. 按装Clink)
    • [1. 安装Oh-My-Posh](#1. 安装Oh-My-Posh)
    • [2. 安装Clink](#2. 安装Clink)
    • [2. 安装后的位置](#2. 安装后的位置)
  • [2. 编写Lua脚本](#2. 编写Lua脚本)
    • [1. oh-my-posh Lua脚本](#1. oh-my-posh Lua脚本)
    • [2. 重启cmd窗口看效果](#2. 重启cmd窗口看效果)

OhMyPosh对Windows CMD 没有现成的支持。 然而可以使用Clink来做到这一点,它同时会增加CMD 体验。按照安装说明进行操作,并确保选择自动启动。

将 Oh My Posh 与 Clink 集成很简单:在 Clink 中创建一个名为 oh-my-posh.lua 的Lua脚本,然后在 cmd 中运行以查找该文件的位置来实现OhMyPosh对Widnows CMD命令窗口的支持

1. 安装Oh-My-Posh

详见:

官网地址:https://chrisant996.github.io/clink

这使用winget命令进行安装,安装后直接重启CMD窗口即可,无需额外的配置

shell 复制代码
# 安装 clink
winget install clink

2. 安装后的位置

安装后位置在 C:\用户\用户名\AppData\Local\clink目录下,如: C:\Users\23013\AppData\Local\clink

2. 编写Lua脚本

1. oh-my-posh Lua脚本

在Clink的安装目录下新建Lua脚本,如在C:\Users\23013\AppData\Local\clink目录下新建名称为oh-my-posh.lua的脚本文件,内容如下

shell 复制代码
load(io.popen('oh-my-posh init cmd'):read("*a"))()

2. 重启cmd窗口看效果

添加后,重新启动 cmd 以使更改生效。

相关推荐
DogDaoDao6 小时前
Windows 双 Shell 全面对比:CMD 与 PowerShell 的技术剖析
windows·shell·测试·powershell·cmd·程序员开发
Vex2une2 天前
PowerShell 7.5新特性解析:跨平台自动化与AI集成实战指南
ai编程·powershell·安全合规·自动化脚本·.net 9·跨平台运维·ssh远程
Vex2une9 天前
PowerShell 发展史:从命令行外壳到跨平台自动化引擎
windows·自动化·azure·powershell·vs code·脚本语言·dsc
Vex2une11 天前
PowerShell ISE 到 VS Code 迁移史:从集成脚本环境到现代编辑器工作流
windows·vscode·powershell·powershell ise·powershell 扩展·powershell 7·脚本编辑器
Vex2une14 天前
Windows PowerShell 发展史:从命令行工具到自动化核心
windows·自动化运维·命令行·powershell·cmd·脚本语言·对象管道
iCxhust16 天前
Powershell脚本,列出近3日打开的文件夹并打开
程序人生·powershell
谷哥的小弟18 天前
基于PowerShell的Chrome无痕访问
chrome·powershell·网络环境·无痕访问
fox_charon23 天前
Windows 下 CLI 参数的引号陷阱:为什么 --resume 'uuid' 会失败
windows·shell·cmd·cli·引号
Blockbuater_drug1 个月前
setx 设完读不到?Windows 系统环境变量作用域、截断坑与 AI 工具密钥管理
注册表·powershell·api key·mcp server·windows 环境变量·setx·环境变量插值
bosins1 个月前
Windows IIS 配置本地HTTPS 全流程指南:自签名证书 + 端口绑定 + 避坑详解
powershell·openssl