zq-file.sh:完善脚本功能(replace/remove/insert等)

This commit is contained in:
2026-03-09 11:54:16 +08:00
parent d03273b42c
commit ad19006a4f
8 changed files with 443 additions and 82 deletions
+26 -8
View File
@@ -73,20 +73,38 @@ This folder is home. Treat it that way.
- **修改工作区文件必须使用脚本 `~/.openclaw/cron/scripts/zq-file.sh`**
- 脚本用法:
```bash
# 编辑文件
~/.openclaw/cron/scripts/zq-file.sh edit <相对路径>
# 读取文件
zq-file.sh read <相对路径>
# 写入/覆盖文件
~/.openclaw/cron/scripts/zq-file.sh write <相对路径> "内容"
zq-file.sh write <相对路径> "内容"
# 追加内容
~/.openclaw/cron/scripts/zq-file.sh append <相对路径> "内容"
# 追加到文件末尾
zq-file.sh append <相对路径> "内容"
# 新建文件
~/.openclaw/cron/scripts/zq-file.sh new <相对路径> "内容"
# 在文件开头插入
zq-file.sh prepend <相对路径> "内容"
# 替换文本(精确匹配,首次)
zq-file.sh replace <相对路径> "旧内容" "新内容"
# 替换所有匹配
zq-file.sh replace-all <相对路径> "旧内容" "新内容"
# 删除特定文本
zq-file.sh remove <相对路径> "要删除的内容"
# 在某行之前插入
zq-file.sh insert-before <相对路径> "标记行" "内容"
# 在某行之后插入
zq-file.sh insert-after <相对路径> "标记行" "内容"
# 删除文件
~/.openclaw/cron/scripts/zq-file.sh delete <相对路径>
zq-file.sh delete <相对路径>
# 新建文件
zq-file.sh new <相对路径> "内容"
```
- 脚本会自动执行:从NAS同步 → 操作文件 → Git提交 → 同步到NAS
- 用户的待办记录到~/work/zq/00.收件箱/01-速记本.md