Gist: https://gist.github.com/aliou/17322b3fa9e816e2231fd4be05005398
A small Pi extension that adds --shebang, inspired by Simon Willison's TIL post Using LLM in the shebang line of a script.
When enabled, Pi treats the first input as a script path, reads that file, strips the shebang line, and sends the remaining body as the prompt.
pi install https://gist.github.com/aliou/17322b3fa9e816e2231fd4be05005398Or test directly:
pi --no-extensions -e https://gist.github.com/aliou/17322b3fa9e816e2231fd4be05005398 -p --shebang=true ./pelican.shCreate pelican.sh:
#!/usr/bin/env -S pi --no-extensions -e https://gist.github.com/aliou/17322b3fa9e816e2231fd4be05005398 -p --shebang=true
Generate an SVG of a pelican riding a bicycleThen run:
chmod +x pelican.sh
./pelican.shWithout -p, Pi opens interactive mode, runs the prompt, and keeps the session open.
Use --shebang=true, not just --shebang. Pi parses unknown flags before extension flags are registered, so a bare --shebang can consume the script path as its value.
Extra script arguments are ignored by this first version. The extension uses only the first input line as the script path.