"Haunted Shell: A Ghost That Lives in My Terminal (Gemma, Fully Offline)" published: false
This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine What I Built Haunted Shell is a ghost that lives in your terminal. After some of the commands you run, it whispers one eerie sentence about what you just did. A failed git push and a rm -rf get very different commentary. I read "Ghost in the Machine" literally. Every developer has felt that the machine is haunted: the bug that vanishes when you add a print statement, the script nobody remembers writing. I gave that ghost a voice. It's a 20-line Python script plus a 3-line zsh hook. A small local model does all the haunting, with no cloud calls and no accounts. Demo [Add a screen recording or GIF of your terminal here, ideally with Wi-Fi visibly off] A sample run (replace with your own real output): $ git push origin main ! [rejected] main -> main (fetch first) ???? Even the remote refuses you now. Something older than Git has already claimed that branch.
This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine
What I Built
Haunted Shell is a ghost that lives in your terminal. After some of the commands you run, it whispers one eerie sentence about what you just did. A failed git push and a rm -rf get very different commentary.
I read "Ghost in the Machine" literally. Every developer has felt that the machine is haunted: the bug that vanishes when you add a print statement, the script nobody remembers writing. I gave that ghost a voice.
It's a 20-line Python script plus a 3-line zsh hook. A small local model does all the haunting, with no cloud calls and no accounts.
Demo
[Add a screen recording or GIF of your terminal here, ideally with Wi-Fi visibly off]
A sample run (replace with your own real output):
$ git push origin main
! [rejected] main -> main (fetch first)
???? Even the remote refuses you now. Something older than Git has already claimed that branch.
Code
[Embed your GitHub repo here: {% embed https://github.com/you/haunted-shell %}]
haunt.py
python
#!/usr/bin/env python3
import json, sys, urllib.request
cmd, code = sys.argv[1], sys.argv[2]
MODEL = "gemma3:1b"
## How I Built It
- **Model:** Gemma 3 (1B), an open-weight model from Google, served locally with Ollama (`ollama pull gemma3:1b`).
- **Glue:** zsh's `preexec` hook captures the command and `precmd` captures its exit code. A tiny Python script sends both to Ollama's local HTTP API.
- **Prompt design:** A short persona prompt does most of the work. The one-sentence limit keeps replies fast, and the ghost stays in character.
- **Restraint:** The ghost speaks after about one in three commands (`RANDOM % 3`), because a ghost that talks constantly gets annoying. It runs in the background so it never blocks the prompt, and it fails silently if the model isn't running.
## Why Does Open Innovation Matter?
- **It works with the lights off.** The whole thing runs on a laptop with no internet, so the ghost still haunts you on a train or in a power cut.
- **Your commands stay yours.** Shell history can contain paths, hostnames, and sometimes secrets. Sending every command to a hosted API for jokes would be a bad trade. With a local model, nothing leaves the machine.
- **It costs nothing per whisper.** A ghost that comments on every command would be expensive on a metered API. Locally it's free.
- **I can change the haunting.** Swapping the model is one string (`MODEL`), and changing the personality is one prompt. A closed service could retire a model version and silently change my ghost's voice.
## My Agent Session
## The Spirit of It
## Prize Categories
**Best Use of Gemma:** the project runs Gemma 3 locally as its only AI component.
nil