21 releases (5 stable)

1.1.3 Feb 13, 2024
0.12.0 Feb 2, 2024
0.11.0 Aug 24, 2023
0.9.0 Jul 31, 2023
0.2.0 Nov 12, 2022

#48 in Configuration

Download history 6/week @ 2024-02-02 30/week @ 2024-02-09 27/week @ 2024-02-16 88/week @ 2024-02-23 17/week @ 2024-03-01 7/week @ 2024-03-08 2/week @ 2024-03-15 76/week @ 2024-03-29 23/week @ 2024-04-05

99 downloads per month

MIT license

135KB
3K SLoC

env-select

license crates.io version

Easily switch between predefined values for arbitrary environment variables Features include (but are not limited to):

  • Interative prompts to select between variable profiles
  • Cascading config system, allowing for system and repo-level value definitions
  • Grab values dynamically via shell commands
  • Modify your shell environment with es set, or run a one-off command in a modified environment with es run
  • Re-use common variables between profiles with inheritance

Example

# .env-select.toml
[applications.server.profiles.dev]
variables = {SERVICE1 = "dev", SERVICE2 = "also-dev"}

[applications.server.profiles.prd]
variables = {SERVICE1 = "prd", SERVICE2 = "also-prd"}

Now pick an environment to export:

> es set server
 === dev ===
SERVICE1=dev
SERVICE2=also-dev

  === prd ===
SERVICE1=prd
SERVICE2=also-prd
> echo $SERVICE1 $SERVICE2
dev also-dev

source Disclaimer

env-select runs as a subprocess to your shell (as all commands do), meaning it cannot modify your shell environment. To get around this, env-select will simply output shell commands that the shell plugins (or you) can then pipe to source (or eval) to modify your session.

If you think piping stuff to source is dangerous and sPoOky, you're right. But consider the fact that at this point, you've already downloaded and executed a mystery binary on your machine. You should've already done your due diligence.

Bugs/Feedback

If you find a bug or have a feature request, please open an issue on GitHub.

Dependencies

~13–24MB
~364K SLoC