Minimal, production-minded Windows text expander built with Zig and SQLite.
text-expander runs as a background service, expands typed triggers globally (for example :bb -> be right back.), and stores snippets in a local SQLite database.
- Fast, native, low-overhead runtime.
- SQLite-backed snippet storage.
- Scriptable CLI for automation and ops.
- Optional terminal UI (TUI) for snippet browsing/editing.
- Global expansion in Windows apps.
- Background service lifecycle:
start,run,stop,status. - Hot reload of snippet changes (no service restart needed for DB edits).
- Multiline snippet support via
addm. - Template tokens in expansions:
{{date}}->YYYY-MM-DD{{time}}->HH:MM{{datetime}}->YYYY-MM-DD HH:MM{{iso_datetime}}-> ISO local datetime{{year}},{{month}},{{day}}
- Built-in safety controls:
- Trigger validation (
:prefix,[A-Za-z0-9_-]). - Max trigger and expansion limits.
- Injected-key filtering to prevent recursive loops.
- Trigger validation (
- Windows
- Zig
0.15.2or newer compatible with this repo winsqlite3.dll(available on supported Windows versions)
Build core CLI:
zig buildBuild TUI:
zig build tuiManual release build (CLI exe):
mkdir dist
zig build-exe src/main.zig -O ReleaseSafe -lc -luser32 -femit-bin=dist/text-expander.exeOr use the release helper:
.\scripts\build-release.ps1.\dist\text-expander.exe doctor
.\dist\text-expander.exe add :bb "be right back."
.\dist\text-expander.exe start
.\dist\text-expander.exe statusThen type :bb + space in any app.
text-expander # start background service
text-expander start # start background service
text-expander run # run foreground (blocking)
text-expander stop # stop service
text-expander status # show status + db path
text-expander add :key "..." # add/update single-line snippet
text-expander addm :key # add/update multiline snippet from stdin
text-expander remove :key # delete snippet
text-expander list # list snippets
text-expander doctor # health check
text-expander tui # prints TUI launch target
text-expander help # usage
The project includes a minimal, keyboard-first TUI powered by libvaxis.
Run:
zig build tui
.\zig-out\bin\text-expander-tui.exeDefault DB path:
%LOCALAPPDATA%\TextExpander\snippets.db
Most CLI commands print db: ... to make support/debugging straightforward.
Planned work is tracked in LINEAR_TODO.md, organized by:
P0ship-ready baselineP1production hardeningP2enterprise readiness
- Keep changes small and focused.
- Preserve Windows reliability first (hook stability, safe shutdown, no recursive input).
- Prefer prepared statements and bounded memory operations.
- Validate with:
zig buildzig build tui- manual smoke test:
start, type trigger,stop
If you are an autonomous coding agent working in this repo:
- Read
build.zigfirst to understand targets (text-expander,text-expander-tui). - Treat
src/main.zigas the service/CLI source of truth. - Keep DB schema backward compatible unless migration is explicit.
- Do not introduce non-Windows assumptions into runtime code paths.
- Keep commands and docs synchronized whenever CLI behavior changes.
- X / updates: @milonspace
- Repository: bymilon/zig-text-expander