A ghost in my shell, powered by a local Gemma
说明与用途
终端幽灵使用本地 Gemma 模型为命令生成上下文评论,且不将数据发送到云端。
问题
Shell commands expose sensitive data; a local LLM can generate contextual comments without leaking history.
结果
The ghost provides timely, model‑generated commentary on shell commands with minimal latency (≈2 s for gemma3:4b) and no external data transfer.
工作流
- Install Ollama and pull gemma3:4b
- Clone haunted‑terminal repo
- Add haunt.sh to ~/.bashrc
- Set optional env vars (HAUNT_ODDS, HAUNT_MODEL, HAUNT_HOST)
- Run commands; ghost whispers appear after command completion
证据
It is about 80 lines: a Bash hook (haunt.sh) on PROMPT_COMMAND and a stdlib-only Python script (whisper.py) that calls Ollama's /api/generate.
Same prompt, 5 commands, 16 cores, no GPU, 14 GB RAM (warm = model already loaded):
12B writes slightly better lines, but 4B is the right default.
Cold start can silence the ghost.
- 记录日期: 2026-10-26T22:11:12.388Z