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.