Skip to content

CLI Reference

Launch the interactive setup wizard to configure secrets for the current directory.

Terminal window
bwenv init

Flow:

  1. Detects available password manager CLIs
  2. Prompts you to select a provider (Bitwarden or 1Password)
  3. Authenticates with the selected provider
  4. Lists folders/vaults — browse with arrow keys, search by typing
  5. Previews the environment variables that will be exported
  6. Generates an .envrc file and auto-approves it via direnv

Example:

Terminal window
$ bwenv init
? Select a provider: Bitwarden
Unlocking vault...
? Select a folder: Production API Keys
Found 12 environment variables from 5 items
Generated .envrc secrets will load automatically via direnv

Export secrets as export KEY=VALUE lines to stdout (non-interactive).

Terminal window
bwenv export --provider <provider> --folder <folder>

Flags:

  • --providerbitwarden or 1password
  • --folder — folder name (Bitwarden) or vault name (1Password)

Examples:

Terminal window
# Print export lines
bwenv export --provider bitwarden --folder "MySecrets"
# Load into current shell
eval "$(bwenv export --provider bitwarden --folder "MySecrets")"
# 1Password
eval "$(bwenv export --provider 1password --folder "Production")"

Re-authenticate with the provider configured in the current .envrc.

Terminal window
bwenv login

Aliases: bwenv auth

Behavior:

  1. Reads the existing .envrc to detect which provider and folder are configured
  2. Re-authenticates with that provider (unlock/sign in)
  3. Updates the session token in .envrc
  4. Auto-approves the updated .envrc via direnv

Use this when your vault session has expired — it’s faster than bwenv init because it skips provider and folder selection.

Example:

Terminal window
$ bwenv login
Re-authenticating with Bitwarden...
Enter master password:
Session updated in .envrc

Lock all vaults and terminate active sessions.

Terminal window
bwenv logout

Behavior:

  • Bitwarden — runs bw lock to lock the vault
  • 1Password — runs op signout to end the session
  • Shows any lingering session environment variables and how to clear them

Show a comprehensive overview of your current bwenv state.

Terminal window
bwenv status

Shows:

  • Current directory and .envrc info (provider, folder)
  • direnv installation and hook status
  • Provider CLI availability and active sessions
  • Relevant environment variables (masked for security)
  • Current config preferences

Open the interactive settings editor.

Terminal window
bwenv config

Settings:

SettingDefaultDescription
Show EmojiONDisplay emoji icons in output
Show Direnv OutputOFFShow/hide direnv’s loading/unloading messages
Show Export SummaryONShow the boxed summary when secrets are loaded via direnv
Auto SyncONAutomatically sync vault before fetching secrets (Bitwarden)

Settings persist to ~/.config/bwenv/config.json.


Approve the .envrc file in the current directory for direnv.

Terminal window
bwenv allow

Equivalent to direnv allow. In TTY mode, also re-authenticates and updates the session if needed.


Revoke direnv approval for the .envrc in the current directory.

Terminal window
bwenv disallow

Equivalent to direnv revoke.


Delete the .envrc file from the current directory.

Terminal window
bwenv remove

Display the version string.

Terminal window
bwenv version

Show usage information and available commands.

Terminal window
bwenv help
bwenv --help
bwenv -h
  • 0 — Success
  • 1 — General error (authentication failure, missing dependencies, etc.)
VariableDescription
BW_SESSIONBitwarden session token (auto-managed by bwenv)
OP_SERVICE_ACCOUNT_TOKEN1Password service account token (for CI/CD)

All custom fields (Bitwarden) or item fields (1Password) from the selected folder/vault become environment variables:

Terminal window
# After bwenv init + direnv allow:
echo $DATABASE_URL
echo $API_KEY
echo $JWT_SECRET

The generated .envrc contains a single eval call:

Terminal window
# bwenv: provider=bitwarden folder="My Secrets"
# Run bwenv login to re-authenticate if session expires
eval "$(BW_SESSION='...' bwenv export --provider bitwarden --folder 'My Secrets')"

No secrets are stored on disk (except session tokens which expire). The .envrc fetches secrets live from your vault each time direnv loads it.

Useful additions to your shell config:

Terminal window
alias bwl='bwenv login'
alias bws='bwenv status'
alias bwi='bwenv init'
alias bwr='bwenv remove'