Skip to main content

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 <env_identifier>

Example .useenv.yml config file:

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.

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:

_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:

...
envs:
    foo:
        DATABASE_PASSWORD: 1pw::<item-id>::<field>  # e.g. 1pw::abcdefqwerty::password

Release files for useenv 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for useenv 0.5.1
File Size Uploaded
useenv-0.5.1.tar.gz 2.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for useenv 0.5.1
File Interpreter ABI Platform
useenv-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 6.3 kB

Release files / useenv-0.5.1.tar.gz

Download URL useenv-0.5.1.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
329b17c490958700376c763855b8000a4f0997e28e684a3c609fefd09b2426fd
BLAKE2b-256 checksum
How to use checksums
c535e9604ad63c7c3f317d6f529e6218a4762dc19d53fe187ff9116fafa473fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.10.6 Darwin/22.6.0

Release files / useenv-0.5.1-py3-none-any.whl

Download URL useenv-0.5.1-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa7c0c128f0b34b54c7ee1cd2808363ca65fbccfb91664d0882fe9f05290e116
BLAKE2b-256 checksum
How to use checksums
5dfdce91bbcf0c9d36d1909357ee30ad68b745be9383ee91337c2413383a6254
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.10.6 Darwin/22.6.0

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page