https://github.com/peter554/useenv
A tiny tool to manage values in your env file
https://github.com/peter554/useenv
Last synced: 3 months ago
JSON representation
A tiny tool to manage values in your env file
- Host: GitHub
- URL: https://github.com/peter554/useenv
- Owner: Peter554
- Created: 2023-10-24T11:16:29.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-11-21T11:14:26.000Z (over 2 years ago)
- Last Synced: 2025-11-28T19:44:06.086Z (8 months ago)
- Language: Python
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# useenv
A tiny tool to manage values in your env file.
Useful in some rare circumstances e.g. swapping variables in local development,
when you don't want to maintain multiple separate env files.
* `pipx install useenv`
* Create a `.useenv.yml` config file in your project root.
* If this contains secret values then make sure to add `.useenv.yml` to your project or global `.gitignore`.
* `useenv `
Example `.useenv.yml` config file:
```yml
env_file: .env
envs:
foo:
DATABASE_HOST: foo-host
DATABASE_USER: foo-user
DATABASE_PASSWORD: foo-pw
bar:
DATABASE_HOST: bar-host
DATABASE_USER: bar-user
DATABASE_PASSWORD: bar-pw
```
## Modes
`--mode` flag or `mode` field of the config.
### `merge` (default)
Values will be merged into the existing env file, or create it if it doesn't exist.
### `create`
Env file will be created/overwritten.
In this case you may want to define a common set of values. YAML gives us the tools to do this:
```yml
_common: &common
DATABASE_USER: common-user
env_file: .env
mode: create
envs:
foo:
<< : *common
DATABASE_HOST: foo-host
DATABASE_PASSWORD: foo-pw
bar:
<< : *common
DATABASE_HOST: bar-host
DATABASE_PASSWORD: bar-pw
```
## 1password
If you have the 1password CLI installed then you can pull values from 1password:
```yml
...
envs:
foo:
DATABASE_PASSWORD: 1pw:::: # e.g. 1pw::abcdefqwerty::password
```