Easily switch between multiple environment variables with the same name.
Project description
Env Setter
Env Setter is a cli package meant to make switching environments simple and easy.
It should just work, but is definitely completely untested.
This package is meant to be useful for developers who work with multiple environments locally.
For example, instead of setting different variables like:
export DEV_INSTANCE_URL=<some url>
export DEV_API_KEY=<some api key>
export DEV_DATABASE=<some database url>
export PREPROD_INSTANCE_URL=<>
export PREPROD_API_KEY=<>
export PREPROD_DATABASE=<>
and then switching between dev and preprod instances for doing things like run some local tests, tasks etc.
you can do it via:
envo-set dev # sets INSTANCE_URL, API_KEY, DATABASE
<some-command> $INSTANCE_URL -H "Authorization: $API_KEY"
envo-set preprod # sets the same environment variables
<some-command> $INSTANCE_URL -H "Authorization: $API_KEY" # same but different instance
Installing env-setter
Use pipx to install pipx on your machine.
pipx install env-setter
envo init
envo init adds the shell alias for envo-set. Since running something always launches a child process, we cannot set the environment variable in the child process. Thus, we have a specific alias that runs eval on the output of envo command to set it up for you.
This is explained more below.
Usage
By default, envo looks in ~/.envs for environments stored in TOML format.
You can override this by setting the ENVS_DIR environment variables.
Each environment should just be a set of key-value pairs, for example:
# let's say in env1.toml
TARGET = "https://someurl.com"
NUM_PROCESSES = 4
And,
# let's say in env2.toml
TARGET = "https://target.com"
NUM_PROCESSES = 2
You can now do the following:
Init a shell
# initializes a shell with the "envo-set" alias, this might need to be run per-shell if you have multiple.
envo init
List available environments
envo list
Output is the name of the files.
env1
env2
Show an environment
envo show env1
Output:
TARGET=https://someurl.com
NUM_PROCESSES=4
The run command for an environment
envo command env2
Output:
export TARGET=https://target.com
export NUM_PROCESSES=2
Set environment variables from a file
envo-set env2
Essentially, envo-set runs the following:
function env_set() {
eval $(envo command $@)
}
alias envo-set="env_set"
This ensures you get automatically get the environment variables in your process.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file env_setter-0.1.0.tar.gz.
File metadata
- Download URL: env_setter-0.1.0.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59c8aa53b8967fc3daa14b106c9016c1775578a2266000cfa1422a9e8c82b924
|
|
| MD5 |
9a2a3c88536d078b499bcff3c7fe93fe
|
|
| BLAKE2b-256 |
f4bf938b78401bc13c875c5d7749fdd0e013617f11598f01c38b8c9c47ffb6f6
|
File details
Details for the file env_setter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: env_setter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae0a6b5b39ca831c454ad29336edef5557b6ae4ea04004c11097961b428ccafa
|
|
| MD5 |
c0f5601018dd2d347e9581906d3d1058
|
|
| BLAKE2b-256 |
454089e9ab6525c5f7a45a20a5187869ae559f2686876bd17792601ecb1282ea
|