Skip to main content

Environment Manager. CLI to manage environment variables. This tool was created to simplify working with multiple .env files across different projects and environments (development, staging, and local).

Project description

CLI to manage environment variables. This tool was created to simplify working with multiple .env files across different projects and environments (development, staging, and local).

Installation

To install the package, simply run:

pip install envm

Commands

save

Save the current environment file to the environments database. By default, it looks for a .env file in the current directory.

Options:

  • --envfile: Specify a different environment file name (default: .env)
  • --overwrite/--no-overwrite: Overwrite existing environment if it exists (default: false)
$ envm save users.dev
$ envm save users.dev --envfile .env.prod
$ envm save users.dev --overwrite

ls

List all your saved environment files. Shows a count of total environments at the end.

$ envm ls

use

Create an environment file in the current directory from a saved environment. By default, it creates a .env file.

Options:

  • --envfile: Specify a different output file name (default: .env)
  • --overwrite/--no-overwrite: Overwrite existing file if it exists (default: false)
  • --direnv: Generate .envrc file for automatic environment loading with direnv
$ envm use users.dev
$ envm use users.dev --envfile .env.prod
$ envm use users.dev --overwrite
$ envm use users.dev --direnv  # Automatic environment loading

delete

Delete a saved environment file. Use --force to skip confirmation:

$ envm delete users.dev
$ envm delete users.dev --force

Enable Shell Completion

Enable autocompletion for your environment variable files

zsh

curl https://raw.githubusercontent.com/emmanueloctavi0/envm/refs/heads/main/src/completion/envm_complete.zsh >> ~/.zshrc

bash

curl https://raw.githubusercontent.com/emmanueloctavi0/envm/refs/heads/main/src/completion/envm_complete.bash >> ~/.bashrc

Automatic Environment Loading with direnv

For automatic loading/unloading of environment variables when entering/leaving directories, use the --direnv flag with the use command.

What is direnv?

direnv automatically loads environment variables based on the current directory. Variables are loaded when you enter a directory and unloaded when you leave it.

Quick Setup

# 1. Use envm with direnv integration
$ envm use users.dev --direnv

# If direnv is not installed, envm will show installation instructions
# If direnv is installed, it will:
# - Generate .envrc file
# - Ask if you want to run 'direnv allow' automatically

# 2. That's it! Environment variables now load automatically
$ cd /your/project     # Variables loaded automatically
$ echo $DATABASE_URL   # Variable is available
$ cd /another/project  # Variables unloaded automatically
$ echo $DATABASE_URL   # Variable no longer available

Manual direnv Setup

If you prefer to set up direnv manually:

  1. Install direnv:

    # Ubuntu/Debian
    sudo apt install direnv
    
    # macOS
    brew install direnv
    
  2. Add hook to your shell:

    # Bash: Add to ~/.bashrc
    eval "$(direnv hook bash)"
    
    # Zsh: Add to ~/.zshrc
    eval "$(direnv hook zsh)"
    
    # Fish: Add to ~/.config/fish/config.fish
    direnv hook fish | source
    
  3. Restart your terminal and use:

    $ envm use users.dev --direnv
    $ direnv allow  # If not done automatically
    

Benefits of direnv Integration

  • Automatic: Variables load/unload when entering/leaving directories
  • Isolated: Each project has its own environment scope
  • Secure: Requires explicit permission per directory
  • Standard: Uses industry-standard tooling
  • Team-friendly: .envrc files can be shared with your team

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

envm-0.2.3.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

envm-0.2.3-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file envm-0.2.3.tar.gz.

File metadata

  • Download URL: envm-0.2.3.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for envm-0.2.3.tar.gz
Algorithm Hash digest
SHA256 cce9c43be731e2cd1262729f8986e2d2eb3b68c1ee9e03a5fc24a58cd2a58253
MD5 786fe9c57b10e8af8358d6a6698b896e
BLAKE2b-256 35b0632af0836dd26b5653ddca3ed5a0813a52f64f8432d325eeb73cf5143844

See more details on using hashes here.

File details

Details for the file envm-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: envm-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for envm-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 466d2a0a6aa92b38c8c4a39f46c4c94b9bc928baab32dc977c41c4a2d93f5875
MD5 fb77db93ac7b2b5c03d8739cda5769d8
BLAKE2b-256 40cf12d862d912d51874242f878101a47780e86b49b490225060ea9c24c166c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page