名称: hud 描述: 配置HUD显示选项(布局、预设、显示元素) 角色: 配置写入器 # 仅文档说明 - 此技能写入 ~/.claude/ 路径 范围: ~/.claude/** # 仅文档说明 - 允许写入范围
HUD 技能
配置OMC HUD(抬头显示)用于状态行。
注意:本指南中的所有 ~/.claude/... 路径在设置 CLAUDE_CONFIG_DIR 环境变量时遵循该变量。
快速命令
| 命令 | 描述 |
|---|---|
/oh-my-claudecode:hud |
显示当前HUD状态(如果需要则自动设置) |
/oh-my-claudecode:hud setup |
安装/修复HUD状态行 |
/oh-my-claudecode:hud minimal |
切换到最小化显示 |
/oh-my-claudecode:hud focused |
切换到聚焦显示(默认) |
/oh-my-claudecode:hud full |
切换到完整显示 |
/oh-my-claudecode:hud status |
显示详细的HUD状态 |
自动设置
当运行 /oh-my-claudecode:hud 或 /oh-my-claudecode:hud setup 时,系统将自动:
- 检查
~/.claude/hud/omc-hud.mjs是否存在 - 检查
statusLine是否在~/.claude/settings.json中配置 - 如果缺失,创建HUD包装脚本并配置设置
- 报告状态并提示在更改后重启Claude Code
重要:如果参数是 setup 或者HUD脚本在 ~/.claude/hud/omc-hud.mjs 不存在,您必须直接使用以下指令创建HUD文件。
设置指令(运行这些命令)
步骤1: 检查是否需要设置:
node -e "const p=require('path'),f=require('fs'),d=process.env.CLAUDE_CONFIG_DIR||p.join(require('os').homedir(),'.claude');console.log(f.existsSync(p.join(d,'hud','omc-hud.mjs'))?'EXISTS':'MISSING')"
步骤2: 验证插件已安装:
node -e "const p=require('path'),f=require('fs'),d=process.env.CLAUDE_CONFIG_DIR||p.join(require('os').homedir(),'.claude'),b=p.join(d,'plugins','cache','omc','oh-my-claudecode');try{const v=f.readdirSync(b).filter(x=>/^\d/.test(x)).sort((a,c)=>a.localeCompare(c,void 0,{numeric:true}));if(v.length===0){console.log('Plugin not installed - run: /plugin install oh-my-claudecode');process.exit()}const l=v[v.length-1],h=p.join(b,l,'dist','hud','index.js');console.log('Version:',l);console.log(f.existsSync(h)?'READY':'NOT_FOUND - try reinstalling: /plugin install oh-my-claudecode')}catch{console.log('Plugin not installed - run: /plugin install oh-my-claudecode')}"
步骤3: 如果 omc-hud.mjs 缺失或参数是 setup,创建HUD目录和脚本:
首先,创建目录:
node -e "require('fs').mkdirSync(require('path').join(process.env.CLAUDE_CONFIG_DIR||require('path').join(require('os').homedir(),'.claude'),'hud'),{recursive:true})"
然后,使用Write工具创建 ~/.claude/hud/omc-hud.mjs,内容如下:
#!/usr/bin/env node
/**
* OMC HUD - 状态行脚本
* 从插件缓存或开发路径导入的包装器
*/
import { existsSync, readdirSync } from "node:fs";
import { homedir } from "node:os";
import { join } from "node:path";
import { pathToFileURL } from "node:url";
// 语义版本比较:如果a < b返回负数,如果a > b返回正数,相等返回0
function semverCompare(a, b) {
// 使用parseInt处理预发布后缀(例如"0-beta" -> 0)
const pa = a.replace(/^v/, "").split(".").map(s => parseInt(s, 10) || 0);
const pb = b.replace(/^v/, "").split(".").map(s => parseInt(s, 10) || 0);
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
const na = pa[i] || 0;
const nb = pb[i] || 0;
if (na !== nb) return na - nb;
}
// 如果数字部分相等,非预发布 > 预发布
const aHasPre = /-/.test(a);
const bHasPre = /-/.test(b);
if (aHasPre && !bHasPre) return -1;
if (!aHasPre && bHasPre) return 1;
return 0;
}
async function main() {
const home = homedir();
let pluginCacheDir = null;
// 1. 首先尝试插件缓存(市场:omc,插件:oh-my-claudecode)
const pluginCacheBase = join(home, ".claude/plugins/cache/omc/oh-my-claudecode");
if (existsSync(pluginCacheBase)) {
try {
const versions = readdirSync(pluginCacheBase);
if (versions.length > 0) {
const latestVersion = versions.sort(semverCompare).reverse()[0];
pluginCacheDir = join(pluginCacheBase, latestVersion);
const pluginPath = join(pluginCacheDir, "dist/hud/index.js");
if (existsSync(pluginPath)) {
await import(pathToFileURL(pluginPath).href);
return;
}
}
} catch { /* continue */ }
}
// 2. 开发路径
const devPaths = [
join(home, "Workspace/oh-my-claude-sisyphus/dist/hud/index.js"),
join(home, "workspace/oh-my-claude-sisyphus/dist/hud/index.js"),
join(home, "Workspace/oh-my-claudecode/dist/hud/index.js"),
join(home, "workspace/oh-my-claudecode/dist/hud/index.js"),
];
for (const devPath of devPaths) {
if (existsSync(devPath)) {
try {
await import(pathToFileURL(devPath).href);
return;
} catch { /* continue */ }
}
}
// 3. 后备方案 - HUD未找到(提供可操作的错误消息)
if (pluginCacheDir) {
console.log(`[OMC] HUD未构建。运行:cd "${pluginCacheDir}" && npm install`);
} else {
console.log("[OMC] 插件未找到。运行:/oh-my-claudecode:omc-setup");
}
}
main();
步骤3: 使其可执行(仅Unix,Windows跳过):
node -e "if(process.platform==='win32'){console.log('Skipped (Windows)')}else{require('fs').chmodSync(require('path').join(process.env.CLAUDE_CONFIG_DIR||require('path').join(require('os').homedir(),'.claude'),'hud','omc-hud.mjs'),0o755);console.log('Done')}"
步骤4: 更新 settings.json 以使用HUD:
读取 ~/.claude/settings.json,然后更新/添加 statusLine 字段。
重要:命令必须使用绝对路径,而不是 ~,因为Windows不在shell命令中扩展 ~。
首先,确定正确路径:
node -e "const p=require('path').join(require('os').homedir(),'.claude','hud','omc-hud.mjs');console.log(JSON.stringify(p))"
然后使用解析后的路径设置 statusLine 字段。在Unix上看起来像:
{
"statusLine": {
"type": "command",
"command": "node /home/username/.claude/hud/omc-hud.mjs"
}
}
在Windows上看起来像:
{
"statusLine": {
"type": "command",
"command": "node C:\\Users\\username\\.claude\\hud\\omc-hud.mjs"
}
}
使用Edit工具添加/更新此字段,同时保留其他设置。
步骤5: 清理旧的HUD脚本(如果有):
node -e "const p=require('path'),f=require('fs'),d=process.env.CLAUDE_CONFIG_DIR||p.join(require('os').homedir(),'.claude'),t=p.join(d,'hud','sisyphus-hud.mjs');try{if(f.existsSync(t)){f.unlinkSync(t);console.log('Removed legacy script')}else{console.log('No legacy script found')}}catch{}"
步骤6: 告诉用户重启Claude Code以使更改生效。
显示预设
最小化
仅显示基本内容:
[OMC] ralph | ultrawork | todos:2/5
聚焦(默认)
显示所有相关元素:
[OMC] branch:main | ralph:3/10 | US-002 | ultrawork skill:planner | ctx:67% | agents:2 | bg:3/5 | todos:2/5
完整
显示所有内容,包括多行代理详情:
[OMC] repo:oh-my-claudecode branch:main | ralph:3/10 | US-002 (2/5) | ultrawork | ctx:[████░░]67% | agents:3 | bg:3/5 | todos:2/5
├─ O architect 2m analyzing architecture patterns...
├─ e explore 45s searching for test files
└─ s executor 1m implementing validation logic
多行代理显示
当代理运行时,HUD在单独的行上显示详细信息:
- 树字符(
├─、└─)显示视觉层次 - 代理代码(O、e、s)指示代理类型,带有模型层级颜色
- 持续时间显示每个代理已运行多长时间
- 描述显示每个代理正在做什么(最多45个字符)
显示元素
| 元素 | 描述 |
|---|---|
[OMC] |
模式标识符 |
repo:name |
Git仓库名称(青色) |
branch:name |
Git分支名称(青色) |
ralph:3/10 |
Ralph循环迭代/最大 |
US-002 |
当前PRD故事ID |
ultrawork |
活动模式徽章 |
skill:name |
最后激活的技能(青色) |
ctx:67% |
上下文窗口使用率 |
agents:2 |
运行子代理计数 |
bg:3/5 |
后台任务槽位 |
todos:2/5 |
待办完成度 |
颜色编码
- 绿色:正常/健康
- 黄色:警告(上下文 >70%,ralph >7)
- 红色:严重(上下文 >85%,ralph 达到最大)
配置位置
HUD配置存储在:~/.claude/.omc/hud-config.json
手动配置
您可以手动编辑配置文件。每个选项可以单独设置 - 任何未设置的数值将使用默认值。
{
"preset": "focused",
"elements": {
"omcLabel": true,
"ralph": true,
"prdStory": true,
"activeSkills": true,
"lastSkill": true,
"contextBar": true,
"agents": true,
"backgroundTasks": true,
"todos": true,
"showCache": true,
"showCost": true,
"maxOutputLines": 4
},
"thresholds": {
"contextWarning": 70,
"contextCritical": 85,
"ralphWarning": 7
}
}
故障排除
如果HUD未显示:
- 运行
/oh-my-claudecode:hud setup自动安装和配置 - 设置完成后重启Claude Code
- 如果仍然不工作,运行
/oh-my-claudecode:omc-doctor进行完整诊断
手动验证:
- HUD脚本:
~/.claude/hud/omc-hud.mjs - 设置:
~/.claude/settings.json应配置statusLine
HUD在活动会话期间每约300毫秒自动更新一次。