Usage Examples
Interactive Setup
Section titled “Interactive Setup”The primary way to use bwenv is through the interactive TUI:
cd /your/projectbwenv initThis walks you through:
- Provider selection — choose Bitwarden or 1Password (auto-detects available CLIs)
- Authentication — master password, biometrics, or existing session
- Folder/vault selection — browse, search, and filter with arrow keys
- Preview — see which variables will be exported
- Generate
.envrc— auto-approved via direnv
Then trigger direnv:
cd . # Reload environmentecho $YOUR_SECRET_VARIABLENon-Interactive Export
Section titled “Non-Interactive Export”For CI/CD pipelines, scripts, or advanced usage:
# Output "export KEY=VALUE" lines to stdoutbwenv export --provider bitwarden --folder "MySecrets"
# Load directly into your shelleval "$(bwenv export --provider bitwarden --folder "MySecrets")"
# Works with 1Password tooeval "$(bwenv export --provider 1password --folder "Production")"Re-authenticate (Session Expired)
Section titled “Re-authenticate (Session Expired)”When your vault session expires, use bwenv login instead of re-running bwenv init:
bwenv loginThis detects the provider from your existing .envrc, re-authenticates, updates the session token, and auto-approves — skipping provider and folder selection entirely.
Alias:
bwenv authworks too.
Configure Preferences
Section titled “Configure Preferences”bwenv configInteractive settings editor to toggle:
| Setting | Default | Description |
|---|---|---|
| Show Emoji | ON | Display emoji icons in output |
| Show Direnv Output | OFF | Show/hide direnv’s loading/unloading messages |
| Show Export Summary | ON | Show the boxed summary when secrets are loaded |
| Auto Sync | ON | Automatically sync vault before fetching (Bitwarden) |
Settings persist to ~/.config/bwenv/config.json.
Status and Diagnostics
Section titled “Status and Diagnostics”bwenv statusShows a comprehensive overview:
- Current directory and
.envrcinfo (provider, folder) - direnv installation and hook status
- Provider CLI availability and active sessions
- Relevant environment variables (masked for security)
- Current config preferences
Lock Vaults / Logout
Section titled “Lock Vaults / Logout”bwenv logoutTerminates all active provider sessions:
- Bitwarden — runs
bw lock - 1Password — runs
op signout - Shows any lingering session variables and how to clear them
Remove Secrets
Section titled “Remove Secrets”bwenv removeDeletes the .envrc file from the current directory.
Allow / Disallow
Section titled “Allow / Disallow”bwenv allow # Approve .envrc for direnvbwenv disallow # Revoke direnv approvalReal-World Examples
Section titled “Real-World Examples”Web Development Project
Section titled “Web Development Project”cd ~/projects/my-webapp
# Interactive setupbwenv init# Select "Bitwarden" → Enter master password → Select "Web App Secrets"
# Secrets are loadedecho $DATABASE_URLecho $API_KEYnpm run devMultiple Environments
Section titled “Multiple Environments”# Developmentcd ~/projects/myapp-devbwenv init # Select "MyApp - Development" folder
# Stagingcd ~/projects/myapp-stagingbwenv init # Select "MyApp - Staging" folder
# Each directory loads its own set of secrets automaticallyCI/CD Pipeline (Bitwarden)
Section titled “CI/CD Pipeline (Bitwarden)”# Set session token from CI secretsexport BW_SESSION="${{ secrets.BW_SESSION }}"
# Load secrets non-interactivelyeval "$(bwenv export --provider bitwarden --folder "Production")"
# Deploy./deploy.sh # $DB_URL, $API_KEY, etc. are availableCI/CD Pipeline (1Password)
Section titled “CI/CD Pipeline (1Password)”# Set service account token from CI secretsexport OP_SERVICE_ACCOUNT_TOKEN="${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}"
# Load secrets non-interactivelyeval "$(bwenv export --provider 1password --folder "Production")"
./deploy.shHow Secrets Are Structured
Section titled “How Secrets Are Structured”Bitwarden
Section titled “Bitwarden”bwenv reads custom fields from items in a folder. Each custom field becomes one environment variable.
Create items in the Bitwarden web vault or app:
- Create a Secure Note or Login item
- Place it in a folder (e.g. “My Project Secrets”)
- Add Custom Fields: field name = env var name, value = env var value
1Password
Section titled “1Password”bwenv reads item fields from items in a vault. The field label becomes the env var name.
Create items in the 1Password app or CLI:
- Create an item in a vault
- Add fields with labels like
DB_HOST,API_KEY, etc.
Notes and OTP fields are skipped.
Tips and Best Practices
Section titled “Tips and Best Practices”- Use
bwenv loginfor expired sessions — faster thanbwenv init - Separate folders per environment — dev, staging, production
- Consistent field names — use the same env var names across environments
- Add
.envrcto.gitignore— never commit secrets - Use
bwenv statusto diagnose issues — checks everything at a glance - Lock vaults when done —
bwenv logoutfor security