foma
Type what you want in plain language, press Alt-Q, and the command line is replaced by the shell command that does it. Nothing is executed: you get a line to read, edit and run yourself.
$ kill whatever is listening on port 8080 <Alt-Q>
$ ss -tlnp | grep ':8080' | awk '{print $6}' | grep -oP 'pid=\K[0-9]+' | xargs kill -9
$ найди битые симлинки в /usr/local <Alt-Q>
$ find /usr/local -xtype l
It is a readline binding plus two dozen lines of bash: your line is sent to a local
OpenAI-compatible chat endpoint together with prompt.txt, and the single-line answer goes back
into the prompt. No daemon, no history, no telemetry, nothing to trust but the line in front of
you.
Requirements
- bash with readline (the helper is bash-specific: it uses
bind -xandREADLINE_LINE) curlandjq- a server exposing
POST /v1/chat/completions— llama.cpp'sllama-server, vLLM, Ollama, or anything else that speaks the same dialect
Any decent instruct model will do. The prompt carries no vendor names and is deliberately model-agnostic; it was developed against a 27B dense model running locally, which answers in 0.3-0.9 s.
Reasoning models need one thing on top, and foma sends it with every request:
chat_template_kwargs: {"enable_thinking": false}. Left to think, such a model spends the whole
256-token budget inside its reasoning and returns an empty answer, which reaches you as
# foma: no answer from ... — on a 27B reasoning model at its default effort, nine of the twelve
test queries came back blank at 6-7 s each; with thinking off, all twelve answered in under 2 s.
A template that does not know the flag ignores it, an unused variable changes nothing.
Install
git clone https://git.3lp.cx/dyadkin/foma
cd foma
./install.sh
install.sh copies nothing. It writes a small per-machine file ~/.foma.bash holding your
settings and a source line pointing back at this clone, then offers to add one line to your
.bashrc. Updating is therefore just git pull — your settings are never touched, and neither
is anything else in your home directory.
Run it again any time: an existing ~/.foma.bash is left alone and the .bashrc line is never
added twice.
Using it without installing
Sourcing the file directly works from any account and leaves no trace after the session ends — handy when you are root on someone else's machine for ten minutes:
FOMA_URL=http://localhost:8080 . /path/to/foma/foma.bash
The prompt is located relative to the script, not through $HOME, so it does not matter whose
shell you are in.
Settings
| Variable | Default | Read |
|---|---|---|
FOMA_URL |
http://localhost:8080 |
on every Alt-Q, so you can repoint it mid-session |
FOMA_KEY |
\eq (Alt-Q) |
when the file is sourced, so set it before |
FOMA_DIR |
directory of foma.bash |
when the file is sourced; set it only to override |
When it will not answer
Every failure comes back as a shell comment, so an accidental Enter costs nothing:
# not a shell task
# foma: jq is not installed
# foma: no answer from http://localhost:8080
The first one is the model refusing the request, and it is worth being precise about who refuses what. Nothing in this tool filters anything: no command is inspected, blocked or executed, and the prompt explicitly allows destructive commands, because you are the one who presses Enter.
The model, however, has its own opinions, and they are not evenly distributed. Refusal training is anchored in English: the same destructive request can come back as a refusal in English and as a working command in another language, and the refusal itself often arrives in English no matter what you asked in. Do not mistake this for a safety feature — it is neither reliable nor symmetric. The only thing standing between a bad line and your filesystem is you, reading it.
Tests
FOMA_URL=http://localhost:8080 ./run_tests.sh
Twelve English and Russian requests through the current prompt.txt, with timings.
If you edit the prompt, run the whole suite rather than the one query you were fixing. Three things about small models are worth knowing before you touch it:
- Examples beat rules. A plainly worded rule is often ignored; the same knowledge added as an example works. Show, do not tell.
- Few-shot examples match by the language of the request. English examples do not cover a Russian question, and vice versa. Add examples in both, on different targets than the tests.
- Any edit can regress a neighbour. Adding one example has been observed to flip an unrelated answer that was already correct. Hence the whole suite, every time.
The name
The helper is really called Bourne, because bash is the Bourne Again SHell. Bourne's Russian passport in the film is issued to one Foma Kiniaev — «Лштшфум Ащьф», a Latin name typed with a Cyrillic layout: exactly right, and completely wrong. Which is the failure mode this thing exists to fix, only backwards.
License
MIT, see LICENSE.