opvar is a small CLI that loads secrets from a password manager by tag (label) and prints shell export commands or JSON.
Today it ships with a single backend, 1Password, but the provider layer is designed so additional backends (e.g. Bitwarden) can plug in without touching the rest of the codebase. The active provider can be selected per machine via ~/.config/opvar/config.yaml or per invocation via --provider.
brew tap mrcat71/tap
brew install mrcat71/tap/opvargo install github.com/mrcat71/opvar/cmd/opvar@latestmake build # produces ./dist/opvar
make install BINDIR="$HOME/.local/bin"- 1Password CLI
oponPATH - An active
opsession (op signin)
opvar <label>Apply the exports to the current shell in one step:
eval "$(opvar my-app)"If you want a shortcut in ~/.zshrc:
opvar-use() { eval "$(command opvar "$@")"; }Avoid shadowing the opvar command itself with an alias, otherwise the plain opvar --help no longer works.
--jsonprint results as JSON instead ofexportlines--strictfail on the first invalid item (default: skip and warn)--provider NAMEoverride the configured provider (e.g.1password)--helpshow usage--v/--versionshow version
- Lists items matching the label via
op item list --tags <label> --format json(server-side filtering, with a slower client-side fallback for oldopversions that don't support--tags). - Fetches each item's details in parallel via
op item get <id> --format json. - For each item:
- Uses each field's
label(oridif label is empty) as the env var name. - Skips notes (
notesPlain/NOTES) and the primary username/password credential.
- Uses each field's
- If an item has no named exportable fields, falls back to:
- Var name = item title
- Value = highest-priority secret field (PASSWORD purpose, then
passwordid/label, then any CONCEALED type).
- Prints
export NAME='value'lines to stdout, one per resolved pair.
Diagnostics (skipped items, fallback notices, duplicate variable names) are written to stderr as warning: ... lines.
Optional YAML config at ~/.config/opvar/config.yaml (override path with $OPVAR_CONFIG, override base dir with $XDG_CONFIG_HOME):
# Default provider; only "1password" is supported today.
provider: 1password
providers:
1password:
# reserved for future per-provider tuning (account, vault, ...)If the file is missing the defaults (provider: 1password) apply, so existing users don't need to create anything.
The --provider CLI flag always wins over the config file.
opvar --v
opvar --versionBoth print the short semantic version (e.g. 0.1.0). When installed via Homebrew or go install, the version is baked in at build time. For local Makefile builds, the version comes from the VERSION file in the repo root.
Tagged releases are built by GitHub Actions + goreleaser. Pushing a vX.Y.Z tag triggers:
- Cross-builds for
darwin/linux×amd64/arm64. - A GitHub Release with archives and
checksums.txt. - An updated Formula push to
mrcat71/homebrew-tap.
See .goreleaser.yaml and .github/workflows/release.yml.