bwenv is a cross-platform CLI tool that bridges your password manager and your shell environment using direnv. It lets you load secrets from Bitwarden or 1Password directly into your project's environment variables β no manual copy-pasting, no secrets in .env files committed to git.
Built with Go, Bubble Tea, and Lipgloss for a fast, beautiful, and truly cross-platform experience.
Managing secrets across projects is painful. .env files get committed by accident, tokens expire and break your workflow, and switching between projects means manual copy-pasting. bwenv solves this by fetching secrets directly from your vault β live, per-directory, automatically.
The original bwenv was built around Makefile, Bash, and PowerShell scripts. That version worked, but keeping the behavior consistent across macOS, Linux, and Windows became harder than it needed to be. The project was rewritten in Go for better cross-platform support, simpler installation, and a single static binary for every platform with zero runtime dependencies beyond your password manager CLI and direnv.
AI coding assistants (Claude Code, Cursor, Copilot, etc.) read your project files and environment to understand context. This creates a unique challenge for secrets:
- Leak prevention β
.envfiles in your project are a risk; AI tools may read or suggest committing them. bwenv keeps secrets in your vault, never on disk. - AI sees zero secrets β The
.envrcfile contains only a reference tobwenv export; no keys, no tokens, no passwords. - Works with AI in the shell β Secrets loaded via direnv are available as environment variables that AI tools inherit from the terminal.
- No more "oops, I committed the .env" β When AI suggests
git add ., there's nothing sensitive to accidentally include. - Share context safely β Share your
.envrcin repos, docs, or with AI without exposing any real credentials.
- π― Pinpoint selection β Load only specific items from a folder via TUI multi-select or
--itemsCLI flag - π Multi-provider support β Works with Bitwarden (
bwCLI) and 1Password (opCLI) - π¨ Beautiful TUI β Interactive provider and folder selection with arrow keys, search, and filtering
- π Automatic
.envrcgeneration β Creates direnv-compatible files that auto-load your secrets - π₯οΈ True cross-platform β Single binary for Linux, macOS, and Windows (amd64 + arm64)
- π Smart diagnostics β
bwenv statuschecks every dependency, session, and config - βοΈ Configurable UI β Toggle emoji, direnv output, export summaries via
bwenv config - π Quick re-auth β Session expired?
bwenv loginre-authenticates and updates your.envrcin one step - π Secure logout β Lock vaults and terminate sessions with
bwenv logout - β‘ Zero runtime dependencies β Just the Go binary + your password manager CLI + direnv
- π¦ Easy installation β Homebrew, Scoop, APT/DNF,
go install, or direct download
| Tool | Required? | Description |
|---|---|---|
| direnv | Yes | Automatically loads/unloads environment variables from .envrc files |
| Bitwarden CLI | One of these | Access your Bitwarden vault from the terminal (bw) |
| 1Password CLI | One of these | Access your 1Password vaults from the terminal (op) |
You need at least one password manager CLI installed. bwenv will detect what's available and let you choose.
Important: You must be logged into your password manager's CLI before running bwenv. Depending on your provider:
- Bitwarden: Run
bw loginfirst (one-time setup), thenbwenv initwill prompt for your master password to unlock.- 1Password: Run
op signinfirst, or rely on desktop app biometrics (op v2).If you haven't logged into the CLI yet, bwenv will fail at the authentication step. See INSTALL.md for detailed setup instructions.
brew tap s1ks1/bwenv
brew install --cask bwenvscoop bucket add bwenv https://github.com/s1ks1/scoop-bwenv
scoop install bwenvDownload the .deb package from the latest release:
# Download (replace VERSION and ARCH as needed)
curl -LO https://github.com/s1ks1/bwenv/releases/latest/download/bwenv_VERSION_amd64.deb
# Install
sudo dpkg -i bwenv_*_amd64.deb# Download (replace VERSION and ARCH as needed)
curl -LO https://github.com/s1ks1/bwenv/releases/latest/download/bwenv_VERSION_amd64.rpm
# Install
sudo rpm -i bwenv_*_amd64.rpmgo install github.com/s1ks1/bwenv@latestmacOS / Linux:
curl -fsSL https://raw.githubusercontent.com/s1ks1/bwenv/main/install.sh | shWindows (PowerShell):
irm https://raw.githubusercontent.com/s1ks1/bwenv/main/install.ps1 | iexgit clone https://github.com/s1ks1/bwenv.git
cd bwenv
make build
make installFor local development, use make run ARGS="status" to build and run the CLI
without installing it globally.
Download the latest binary for your platform from the Releases page, extract it, and place bwenv somewhere in your PATH.
bwenv statusFor detailed installation instructions on all platforms, including testing workflows for Bitwarden and 1Password, see INSTALL.md.
bwenv initThis launches a full interactive TUI flow:
- Select a provider β Choose between Bitwarden, 1Password (or whichever CLIs you have installed)
- Authenticate β Unlock your vault or sign in (master password, biometrics, etc.)
- Pick a folder β Browse, search, and select the folder/vault containing your secrets
- Pick specific items β Choose individual items to load, or load all items in the folder
- Generate
.envrcβ A direnv-compatible file is created in the current directory
Then just:
cd . # Trigger direnv to load secretsYour secrets are now loaded as environment variables every time you cd into this directory! π
For CI/CD pipelines, scripts, or advanced usage, you can export secrets directly:
# Output "export KEY=VALUE" lines to stdout
bwenv export --provider bitwarden --folder "MySecrets"
# Export only specific items from a folder
bwenv export --provider bitwarden --folder "MySecrets" --items "item-id-1,item-id-2"
# Use with eval to set variables in the current shell
eval "$(bwenv export --provider bitwarden --folder "MySecrets")"
# Works with 1Password too
eval "$(bwenv export --provider 1password --folder "Production")"bwenv configOpens an interactive settings editor where you can toggle:
| Setting | Default | Description |
|---|---|---|
| Show Emoji | ON | Display emoji icons in output (turn off for cleaner text-only output) |
| Show Direnv Output | OFF | Show/hide direnv's own loading/unloading messages |
| Show Export Summary | ON | Show the boxed summary when secrets are loaded via direnv |
| Auto Sync | ON | Automatically sync the vault before fetching secrets (Bitwarden) |
Settings are persisted to ~/.config/bwenv/config.json.
bwenv loginIf your vault session has expired, bwenv login will:
- Detect which provider is configured in your
.envrc - Re-authenticate with that provider (unlock/sign in)
- Update the session token in your
.envrc - Auto-approve the updated
.envrcvia direnv
This is much faster than running bwenv init again β it skips provider and folder selection entirely.
Alias:
bwenv authworks too.
bwenv logoutTerminates all active provider sessions for security:
- Bitwarden β runs
bw lockto lock the vault - 1Password β runs
op signoutto end the session - Shows any lingering session environment variables and how to clear them
Use this when you're done working with secrets or stepping away from your machine.
bwenv statusShows a comprehensive overview of your current bwenv state:
- Current directory and
.envrcinfo (provider, folder) - direnv installation and hook status
- Provider availability and active sessions
- Relevant environment variables (masked for security)
- Current config preferences
bwenv removeDeletes the .envrc file from the current directory.
bwenv versionββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β bwenv init ββββββΈβ Provider CLI ββββββΈβ .envrc β
β (TUI flow) β β (bw / op) β β (generated) β
ββββββββββββββββ ββββββββββββββββ ββββββββ¬ββββββββ
β
βΌ
ββββββββββββββββ
β direnv β
β (auto-load) β
ββββββββ¬ββββββββ
β
βΌ
ββββββββββββββββ
β Environment β
β Variables β
β $API_KEY β
β $DB_URL β
β $SECRET β
ββββββββββββββββ
bwenv initwalks you through an interactive setup β pick your provider, folder, and optionally specific items- It generates an
.envrcfile that contains a singleevalcall tobwenv export - When direnv loads the
.envrc, it runsbwenv exportwhich fetches fresh secrets from your vault - Each secret's custom fields (Bitwarden) or item fields (1Password) are exported as environment variables
No secrets are stored on disk (except session tokens which expire). The .envrc fetches secrets live from your vault each time direnv loads it.
bwenv/
βββ main.go # Entry point and CLI routing
βββ INSTALL.md # Detailed install & testing guide
βββ install.sh # macOS/Linux quick install script
βββ install.ps1 # Windows quick install script
βββ internal/
β βββ provider/
β β βββ provider.go # Provider interface and registry
β β βββ bitwarden.go # Bitwarden (bw CLI) implementation
β β βββ onepassword.go # 1Password (op CLI) implementation
β βββ ui/
β β βββ styles.go # Lipgloss color palette and shared styles
β β βββ output.go # Styled print helpers (success, error, etc.)
β β βββ provider_picker.go # Bubble Tea model for provider selection
β β βββ folder_picker.go # Bubble Tea model for folder selection
β β βββ init_flow.go # Orchestrates the full init TUI flow
β β βββ login_flow.go # Re-authentication flow for expired sessions
β β βββ config_flow.go # Interactive config editor TUI
β β βββ logout_flow.go # Vault locking and session termination
β β βββ status_flow.go # Status overview & diagnostics
β βββ envrc/
β β βββ envrc.go # .envrc generation, export, allow/disallow
β βββ config/
β βββ config.go # Persistent user preferences (~/.config/bwenv/)
βββ Makefile # Build, install, test, release targets
βββ .goreleaser.yml # GoReleaser config for cross-platform releases
βββ .github/workflows/ # GitHub Actions workflows
βββ packaging/
β βββ homebrew/bwenv.rb # Homebrew formula template
β βββ windows/bwenv.cmd # Windows command shim
β βββ scoop/bwenv.json # Scoop manifest template
βββ LICENSE
βββ README.md
make build # Build for current platform β dist/bwenv
make run # Build and run
make run ARGS="status" # Build and run with argumentsmake test # Run all Go tests
make lint # Run go vet + staticcheck
make fmt # Format all Go source files
make tidy # Clean up go.mod/go.summain is the stable branch and release source. Work on feature branches, open a
pull request, and merge the branch back into main when checks pass. This keeps
the history easy to follow and makes a fresh clone straightforward:
git clone https://github.com/s1ks1/bwenv.git
cd bwenv
git switch main
make buildFor local pulls, prefer merge-based updates:
git config pull.rebase false
git pull origin main# Local test build (no publish)
goreleaser release --snapshot --clean
# Full release (requires GITHUB_TOKEN)
goreleaser release --clean
# Or use the Makefile for a simple cross-compile
make release- Create a new file in
internal/provider/(e.g.doppler.go) - Implement the
Providerinterface (including theLock()method) - Call
Register(&YourProvider{})in aninit()function - That's it β the provider will automatically appear in the TUI picker and CLI flags
| Provider | CLI Tool | Status | Notes |
|---|---|---|---|
| Bitwarden | bw |
β Ready | Reads custom fields from items in folders |
| 1Password | op |
β Ready | Reads fields from items in vaults |
Want another provider? Open an issue or submit a PR! The provider interface is designed to be easy to extend.
If you're upgrading from the original Bash-based bwenv:
-
Uninstall the old version:
# If installed via the old install.sh or make: rm -f ~/.local/bin/bwenv rm -f ~/.config/direnv/lib/bitwarden_folders.sh # If installed via Homebrew: brew uninstall --cask bwenv
-
Install the new version:
brew tap s1ks1/bwenv brew install --cask bwenv
-
Re-initialize your projects:
cd your-project bwenv init # New interactive TUI flow direnv allow
-
Configure preferences (optional):
bwenv config # Toggle emoji, direnv output, etc.
| v1 (Bash) | v2 (Go) | |
|---|---|---|
| Language | Bash + batch scripts | Go (single binary) |
| Providers | Bitwarden only | Bitwarden + 1Password (extensible) |
| Dependencies | bw, jq, direnv |
bw or op, direnv (no jq needed!) |
| UI | Basic terminal prompts | Beautiful TUI with Bubble Tea + Lipgloss |
| Windows | .bat file with PowerShell fallbacks |
Native .exe binary |
| Helper scripts | bitwarden_folders.sh + bwenv bash script |
None β everything is in the single binary |
| Config | None | Persistent preferences via bwenv config |
| Session management | Manual | bwenv login to re-auth, bwenv logout to lock vaults |
| Status overview | None | bwenv status for quick state check |
MIT License. See LICENSE for details.
Pull requests are welcome! For major changes, please open an issue first to discuss what you'd like to change.
The codebase is intentionally well-commented to make it easy for contributors who may not be deeply familiar with Go, Bubble Tea, or Lipgloss.