For PowerShell on Windows 10.
By default this function attempts to locate a .env
file in the current folder.
If the file is found, tries to load the environment variables set on it into the current terminal session.
Load-DotEnv
You can pass the path to any other file containing the variables you want to load as first argument.
Load-DotEnv ..\.env.production
If you want to automatically load the variables if a .env
file exists after cd
ing into a folder, you can put this command inside the prompt()
function in your profile script.
The environment variables are expected to be written in format: export VARIABLE=value
, where value
can be surrounded by these quotation marks: "
, '
, and `
.