Skip to content

Configuration

Controls the debug output level:

  • BWENV_DEBUG=0: Silent mode (errors only)
  • BWENV_DEBUG=1: Show processing steps, hide secret values (default)
  • BWENV_DEBUG=2: Show processing steps and actual secret values (full debug)
Terminal window
# Set for single command
BWENV_DEBUG=2 bwenv init
# Set for direnv operations
BWENV_DEBUG=1 direnv allow
# Export for session
export BWENV_DEBUG=2
bwenv interactive

Bitwarden session token (managed automatically by bwenv):

Terminal window
# Typically set automatically when you unlock Bitwarden
export BW_SESSION="your-session-token"
  • --debug[=LEVEL], -d: Enable debug mode (level 1 or 2)
  • --quiet, -q: Quiet mode (minimal output)
  • --help, -h: Show help information
  • --version, -v: Show version information
Terminal window
# Debug modes
bwenv --debug init # Level 2 (full debug)
bwenv --debug=1 init # Level 1 (steps only)
bwenv --debug=2 init # Level 2 (full debug)
# Quiet mode
bwenv --quiet init
bwenv -q init
# Help and version
bwenv --help
bwenv --version
  • Helper Script: ~/.config/direnv/lib/bitwarden_folders.sh
  • CLI Executable: ~/.local/bin/bwenv (Unix/macOS) or %USERPROFILE%\.local\bin\bwenv.bat (Windows)
  • Environment File: .envrc (created in project directory)
  • Backup: .envrc.bak (created automatically if .envrc exists)
  1. Bitwarden CLI installed: bw --version should work
  2. Logged in: bw login (one-time setup)
  3. Folder organization: Secrets stored in organized folders
Bitwarden Vault
├── Personal/
├── Work Projects/
│ ├── ProjectA - Development
│ ├── ProjectA - Staging
│ ├── ProjectA - Production
│ └── ProjectB - Development
└── Shared Tools/
├── CI/CD Secrets
└── Development Tools

Bitwarden items should use Custom Fields for environment variables:

Example Item: “Database Configuration”

  • Name: Database Configuration
  • Custom Fields:
    • DATABASE_URLpostgresql://user:pass@localhost:5432/myapp
    • DB_POOL_SIZE20
    • DB_TIMEOUT30
    • REDIS_URLredis://localhost:6379
  1. direnv installed: direnv --version should work
  2. Shell hook configured:
    Terminal window
    # Add to ~/.bashrc, ~/.zshrc, etc.
    eval "$(direnv hook bash)" # for bash
    eval "$(direnv hook zsh)" # for zsh

The bitwarden_folders.sh helper script is installed to ~/.config/direnv/lib/ and provides:

  • load_bitwarden_folder(): Main function to load secrets
  • Session management
  • Error handling
  • Debug output

Available commands for project management:

Terminal window
make help # Show all available commands
make install # Install bwenv CLI and helper scripts
make setup-path # Add ~/.local/bin to PATH (Linux/macOS)
make uninstall # Remove bwenv CLI and helper scripts
make test # Run installation tests
  • Auto-unlock: bwenv will prompt for master password if needed
  • Session timeout: Respects Bitwarden CLI session timeout
  • Manual lock: Use bw lock to manually lock session

bwenv creates .envrc files with restricted permissions:

Terminal window
# .envrc permissions (readable by owner only)
-rw------- 1 user user .envrc
  1. Lock when done: Always bw lock after work
  2. Separate environments: Use different folders for dev/staging/prod
  3. Regular rotation: Rotate secrets regularly
  4. Team access: Use Bitwarden Organizations for team sharing
  5. Version control: Add .envrc to .gitignore
  1. direnv not loading:

    Terminal window
    # Check direnv hook is in shell config
    grep direnv ~/.bashrc ~/.zshrc
    # Check direnv status
    direnv status
  2. Bitwarden session issues:

    Terminal window
    # Check status
    bw status
    # Re-login if needed
    bw login
    # Unlock vault
    bw unlock
  3. PATH issues:

    Terminal window
    # Check if bwenv is in PATH
    which bwenv
    # Add to PATH manually
    export PATH="$HOME/.local/bin:$PATH"
Terminal window
# Test complete setup
bwenv test
# Check Bitwarden folders
bw list folders
# Debug bwenv with full output
BWENV_DEBUG=2 bwenv interactive
# Check direnv configuration
direnv status
# Manual helper script test
source ~/.config/direnv/lib/bitwarden_folders.sh

If you need different installation paths, manually copy files:

Terminal window
# Custom CLI location
cp setup/bwenv /your/custom/bin/path/
# Custom helper location
cp setup/bitwarden_folders.sh /your/custom/direnv/lib/

For automated environments:

Terminal window
# Use service account or API key
export BW_CLIENTID="your-client-id"
export BW_CLIENTSECRET="your-client-secret"
# Use quiet mode
bwenv --quiet init
# Bypass interactive prompts
echo "folder-name" | bwenv init