Fetches only the named groups, injects them into the child environment and filters secret values (raw, JSON, URL-encoded) from stdout/stderr. Queries gain an optional 'name'; ENVBAO_CONFIG selects an alternative config. Includes plan 002. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
EnvBao
Inject environment variables from a running OpenBao server into your shell.
envbao is a single self-contained binary designed to be called from ~/.zshrc or ~/.bashrc:
eval "$(envbao)"
It reads ~/.envbao/config.toml, fetches the secrets selected by your queries, and prints
safely quoted export statements for your shell to evaluate.
Features
- Security first - refuses to run unless
~/.envbaoand everything in it is accessible by you only; all failures print nothing to stdout, so a failed run can never half-configure your shell. See docs/security.md. - Config-driven queries - choose exactly which secrets, keys, prefixes and renames you want.
- KV v1 and v2 with automatic version detection. Other credential engines are planned and slot into an engine registry.
- Audited - issues are logged to stderr,
~/.envbao/envbao.log(mode 0600) and the system log. Tokens and secret values are never logged. - Single binary, no runtime dependencies (built with PyInstaller).
- bash, zsh, sh and fish output.
Install
Download the binary for your platform from the project's releases page
(envbao-<version>-linux-amd64, -linux-arm64, -macos-arm64) along with SHA256SUMS.
EnvBao is a single self-contained file: there is no installer and nothing to symlink. Verify
it, then copy it onto your PATH (~/.local/bin shown):
shasum -a 256 -c SHA256SUMS --ignore-missing # Linux: sha256sum -c SHA256SUMS --ignore-missing
# macOS, only if downloaded through a browser (clears the quarantine flag):
xattr -d com.apple.quarantine envbao-*-macos-arm64
install -m 755 envbao-<version>-<platform> ~/.local/bin/envbao
envbao --version
install copies the file and sets its mode in one step. Make sure ~/.local/bin is on your
PATH. To track a local build instead of copying, symlink it:
ln -s "$PWD/dist/envbao" ~/.local/bin/envbao.
Or run from source: uv sync && uv run envbao --help.
Quick start
envbao --init # creates ~/.envbao (0700) and a template config.toml (0600)
$EDITOR ~/.envbao/config.toml # add server address, token and queries
envbao --check # verify permissions, config and token (prints no secrets)
Add to ~/.zshrc or ~/.bashrc:
command -v envbao >/dev/null && eval "$(envbao)"
Caveat:
PATHmust already includeenvbaowhere this line runs. The guardcommand -v envbaois evaluated at that point in the file. If~/.local/bin(or wherever you installed the binary) is only added toPATHlater in your.zshrc/.bashrc(a common case with Oh My Zsh, nvm or pyenv snippets), the guard fails and the line is silently skipped: no variables are loaded, yet runningeval "$(envbao)"by hand later works.Either put the line after your last
PATHchange, or avoid the dependency by using the full path:[ -x "$HOME/.local/bin/envbao" ] && eval "$("$HOME/.local/bin/envbao")"To debug, open a new shell and run
command -v envbao; if it prints nothing,PATHis the problem. Remember that a failingenvbaoalso prints nothing to stdout by design, so check stderr and~/.envbao/envbao.logfor the reason.
Example ~/.envbao/config.toml
[server]
address = "https://bao.example.com:8200"
token = "s.xxxxxxxx" # or: token_file = "~/.envbao/token"
[[query]]
mount = "secret"
path = "myapp/prod"
keys = ["DB_URL", "API_KEY"] # optional filter
prefix = "MYAPP_" # optional
rename = { DB_URL = "DATABASE_URL" } # optional (applied before prefix)
on_missing = "warn" # "warn" (default) or "error"
Full reference: docs/configuration.md.
Exit codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Other failure |
| 2 | Command-line usage error |
| 69 | Server unreachable or returned an unexpected response |
| 77 | Token rejected by the server |
| 78 | Bad configuration or unsafe file permissions |
Documentation
- Usage
- Configuration reference
- Security model
- Migrating from ~/.zshrc
- Development
- Releasing and CI
- Plans
Development
uv sync --all-groups
uv run pytest --cov # tests (coverage gate: 90%)
uv run ruff check . && uv run mypy
uv run pyinstaller envbao.spec # builds dist/envbao
Licence
BSD 3-Clause. See LICENSE.