Summary
A non-standard builtin to load .env files into the shell environment. Every modern project has a .env file. Currently requires export $(cat .env | xargs) which breaks on quotes, comments, and multiline values.
Proposed Syntax
dotenv [OPTIONS] [file...]
Proposed Flags
| Flag |
Description |
| (default) |
Load .env in current directory |
-f FILE |
Load specific file |
-e / --export |
Also export variables (default: shell-local) |
-o / --override |
Override existing variables (default: skip existing) |
-p / --print |
Print loaded variables without setting them |
--prefix PREFIX |
Add prefix to all variable names |
.env Format Support
# Comments
KEY=value
KEY="quoted value"
KEY='single quoted'
KEY="multi\nline"
EMPTY=
# No value (set to empty)
BARE_KEY
# Variable interpolation
BASE=/app
DATA=${BASE}/data
Use Cases
# Load defaults
dotenv
# Load specific env
dotenv -f .env.production --export
# Load without overriding existing
dotenv -f .env.defaults
# Preview what would be loaded
dotenv -p -f .env.staging
# Load with prefix (for namespacing)
dotenv --prefix DB_ -f database.env
# DB_HOST, DB_PORT, etc.
llm_hint()
Some("dotenv: Load .env files. `dotenv` loads .env, `dotenv -f .env.prod -e` loads and exports. Handles quotes, comments, interpolation.")
Summary
A non-standard builtin to load
.envfiles into the shell environment. Every modern project has a.envfile. Currently requiresexport $(cat .env | xargs)which breaks on quotes, comments, and multiline values.Proposed Syntax
Proposed Flags
.envin current directory-f FILE-e/--export-o/--override-p/--print--prefix PREFIX.env Format Support
Use Cases
llm_hint()