julianromli/opencode-template

windows-safe-grep

Use when grep/ripgrep fails on Windows due to paths with backslash-space sequences creating malformed paths like 'nul' from \n+ul

查看源码

使用方法

  1. 复制安装命令,在自己的智能体环境安装前先检查源码包。
  2. 从原始文档核对所需工具、凭据和支持的宿主。
  3. 说明输入材料与期望交付物,并对照来源检查输出。
npx skills add https://github.com/julianromli/opencode-template --skill windows-safe-grep

开始前需了解

  • 安装不包含模型订阅、API 额度或访问文件的权限。
  • 仓库星数和安装量反映活跃情况,不等于独立质量或安全测试。
仓库原始内容

按源仓库内容呈现,保留标题、案例、代码、表格、链接以及原文引用的演示图片。

Windows-Safe Grep Skill

Problem

On Windows, paths containing backslash-space sequences (e.g., D:\Projects\Vibe Code\isometricid) can cause ripgrep to fail because:

  • The \n in isometricid is interpreted as a newline character
  • Combined with the following ul, this creates a reference to the reserved Windows device name nul
  • Error: rg: D:\Projects\Vibe Code\isometricid\nul: Incorrect function. (os error 1)

Solution

Use bash commands with proper path quoting to work around this Windows-specific issue:

Safe Grep Command Pattern

bash
rg --fixed-strings "SEARCH_TERM" "/d/Projects/Vibe Code/isometricid"

Or use forward slashes and proper quoting:

bash
rg --fixed-strings "SEARCH_TERM" "$(cygpath -u "D:\Projects\Vibe Code\isometricid")"

Alternative: Use find + grep

bash
find "/d/Projects/Vibe Code/isometricid" -type f \( -name "*.ts" -o -name "*.js" -o -name "*.tsx" -o -name "*.jsx" \) -exec grep -H --line-number "SEARCH_TERM" {} \;

Usage

When grep fails with "Incorrect function (os error 1)" on Windows:

  1. Use this skill
  2. Replace the path with forward slashes: D:\Projects\Vibe Code\isometricid → /d/Projects/Vibe Code/isometricid
  3. Or use the bash command pattern with proper quoting

Example

bash
rg --fixed-strings "polar_product_id" "/d/Projects/Vibe Code/isometricid/src"
来自同一仓库

更多 Skills

全部 Skills