Motivation
Closes the discoverability loop for the read-only command set (ls #3, cat #4, dump #5). dump works for cross-memo search via the terminal's own search (e.g. WezTerm QuickSearch), but a dedicated search command is more efficient for the common "find lines that mention X" case and produces output (path:line:match) that pipes naturally into pickers like fzf.
Spec
zemo search <query> — print lines matching <query> across scratch and all topic files.
- Targets:
- Match semantics: fixed-string, case-sensitive substring match. (Regex / case-insensitive can be added later.)
- Output format:
<relative-path>:<line-number>:<line-content> per match, one per line. Path is relative to <memo> (e.g. topics/git.md:42:see also git rebase). Matches git grep -n style so output pipes into fzf, bat, etc.
- Ordering: scratch first, then topics alphabetical (matching
dump). Within a file, order by line number ascending.
- Missing files: scratch missing → skip silently.
topics/ missing → skip silently. Both missing → no output, exit 0.
- No matches: no output, exit 1 (standard
grep-like behaviour).
- Empty query: usage error, exit 2.
- Read-only: no git operations.
Example
$ zemo search rebase
scratch.txt:3:remember to git rebase before push
topics/git.md:12:`git rebase --interactive` to squash commits
topics/git.md:34:rebase vs merge — use rebase for feature branches
Implementation note
Implement as a Zig file walk over <memo>/scratch.txt and <memo>/topics/*.md, line-by-line fixed-string match. No git dependency, consistent with cat (#4), ls (#3), dump (#5). Memo repos are personal-scale (hundreds to low thousands of small markdown files), so a straightforward Zig walk is expected to be fast enough indefinitely.
Scope
In:
- Resolve
<memo> via ZEMO_DIR → default.
- Walk
scratch.txt + topics/*.md, fixed-string match, write path:line:content to stdout.
- No-match → exit 1. Empty query → exit 2.
Out (separate issues):
--regex / -E
--ignore-case / -i
--files-only / -l
--topic <topic> (scope to one file)
--context <n> / -C
- Color output
Acceptance criteria
Motivation
Closes the discoverability loop for the read-only command set (
ls#3,cat#4,dump#5).dumpworks for cross-memo search via the terminal's own search (e.g. WezTerm QuickSearch), but a dedicatedsearchcommand is more efficient for the common "find lines that mention X" case and produces output (path:line:match) that pipes naturally into pickers like fzf.Spec
zemo search <query>— print lines matching<query>across scratch and all topic files.<memo>/scratch.txt<memo>/topics/*.md.mdfiles undertopics/, matchingdump(feat: addzemo dumpcommand #5) andls(feat: addzemo lscommand #3).<relative-path>:<line-number>:<line-content>per match, one per line. Path is relative to<memo>(e.g.topics/git.md:42:see also git rebase). Matchesgit grep -nstyle so output pipes intofzf,bat, etc.dump). Within a file, order by line number ascending.topics/missing → skip silently. Both missing → no output, exit 0.grep-like behaviour).Example
Implementation note
Implement as a Zig file walk over
<memo>/scratch.txtand<memo>/topics/*.md, line-by-line fixed-string match. Nogitdependency, consistent withcat(#4),ls(#3),dump(#5). Memo repos are personal-scale (hundreds to low thousands of small markdown files), so a straightforward Zig walk is expected to be fast enough indefinitely.Scope
In:
<memo>viaZEMO_DIR→ default.scratch.txt+topics/*.md, fixed-string match, writepath:line:contentto stdout.Out (separate issues):
--regex/-E--ignore-case/-i--files-only/-l--topic <topic>(scope to one file)--context <n>/-CAcceptance criteria
zemo search <query>prints all matching lines acrossscratch.txtandtopics/*.mdinpath:line:contentformat..mdfiles and subdirectories undertopics/are excluded.zig build testpasses.zemo searchand an fzf integration recipe.