cd /news/ai-tools/i-haunted-my-terminal-with-a-local-g… · home › topics › ai-tools › article
[ARTICLE · art-158339] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=↑ positive

I Haunted My Terminal With a Local Ghost (Gemma 3, No Internet Needed)

A developer built shell-ghost, an open-source zsh hook that uses preexec and precmd to capture each command and its exit code, then sends them to a local Gemma 3 4B model via Ollama's HTTP API to print a single eerie one-line whisper after roughly one in three commands. The tool runs entirely offline, with a temperature of 0.9 and a 48-token cap keeping replies short, and the author argues that routing terminal commands to a hosted API for a joke would be a bad trade given the secrets a shell can expose.

by read2 min views2 publishedOct 26, 2026

This is a submission for the Hacktoberfest Open-Source AI Challenge: Week 4, "Ghost in the Machine".

shell-ghost is a haunted terminal. After some of the commands you run, a ghost whispers one eerie line about what you just did:

$ rm -rf node_modules
  👻 Don't worry, it just wanted a little... tidier oblivion.

$ git push --force
  👻 Don't you dare rewrite my carefully crafted digital chaos.

$ sudo make me a sandwich
  👻 It wants fillings… and a very long, slow, digital chew.

By default it speaks on about 1 in 3 commands, so it stays a surprise instead of a nuisance.

Repo: https://github.com/GAlmeidaDev/shell-ghost

Two tiny files, no dependencies beyond Python 3 and zsh:

haunt.zsh hooks into zsh with preexec (to remember the command) and precmd (to read its exit code). It rolls a die, and if the ghost is feeling chatty it calls the script.ghost.py sends the command and exit code to a local model through Ollama's HTTP API and prints one dim purple line. The whole prompt is a few lines: you are a ghost trapped inside a computer, reply with one short eerie whisper, spooky and a little funny. Temperature 0.9 and a 48-token cap keep it short and weird.

Try it:

ollama pull gemma3:4b
python3 ghost.py "rm -rf node_modules" --code 1
echo 'source /path/to/shell-ghost/haunt.zsh' >> ~/.zshrc

Set GHOST_ODDS=1 and it speaks after every command.

A terminal sees everything: your commands, paths, hostnames, sometimes secrets typed inline. Sending that to a hosted API for a joke would be a bad trade.

With an open-weight model running locally:

localhost.--model swaps in any model Ollama can run. A 4B model is plenty for one spooky sentence, and that's the point: small, open models are good enough to make tools feel alive without a cloud dependency.

splitlines()[0] is still a cheap safety net.

── more in #ai-tools 4 stories · sorted by recency
── more on @shell-ghost 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/i-haunted-my-termina…] indexed:0 read:2min 2026-10-26 · —