confix
A small, dependency-free tool that edits configuration files in place with a tiny command grammar — update, add, comment, uncomment, or delete keys. Ships as a bash script and a zero-dependency JavaScript library + CLI (@budhash/confix), kept identical by a shared spec.
Runs confix's command logic client-side — a JavaScript port of the bash script, validated against its output. Nothing is sent anywhere.
With Homebrew (macOS / Linux):
brew install budhash/tools/confix
Or grab the latest released script (branch-independent) and make it executable:
curl -kL https://github.com/budhash/confix/releases/latest/download/confix > confix chmod +x confixoptions
- -finput file (or -f - / omit to read stdin)
- -ooutput file; -o- prints to stdout, leaving the input untouched
- -ddry run — print a unified diff, write nothing
- -eread commands from a file (one per line)
- -sseparator character (default =)
- -ccomment character (default #)
# update a port, enable a flag, comment one out, add a timeout
confix -f app.properties "port=9090" ">debug=true" "<log.level" ">timeout=30"
Each argument (or each line of a -e file) is one command; the first character selects the operation. Key/value split on the first =, independent of the file separator.
| key=value | update an existing key (no-op if the key is absent) |
| >key=value | set the key, appending it to the file if absent |
| >key | uncomment an existing key |
| <key | comment out an existing key (the line is kept) |
| !key | delete the key's line entirely (active or commented) |
More examples and the full reference are in the README.
The same behavior as a zero-dependency npm package: a library (Node and the browser) and a cross-platform CLI that mirrors the flags above. Both track the bash tool via a shared spec and conformance suite.
npm i @budhash/confix
// library — text in, text out
import { applyBlock } from "@budhash/confix";
applyBlock(text, "port=9090\n>debug=true\n!obsolete", { sep: "=" });
# CLI — same flags as the script, works on Windows too
npx @budhash/confix -f app.properties "port=9090" ">debug=true"