SEVP is a lightweight CLI/TUI tool designed to simplify switching between environment variable values.
Note
SEVP uses a shellhook to set environment variables for the current shell. It currently supports:
zshbash
SEVP helps you quickly switch between predefined values for environment variables with a simple and interactive interface. For example:
- Select an AWS profile by setting the
AWS_PROFILEvariable. - Switch Docker contexts by setting the
DOCKER_CONTEXTvariable. - Manage custom environment variables for your projects.
Important
SEVP will create a default config file at $HOME/.config/sevp.toml if it doesn't exist when you run it for the first time.
Running sevp without arguments uses the default target from your configuration. It launches a TUI where you can select a value for the environment variable.
$ sevpFor example, selecting an AWS profile will set the AWS_PROFILE variable.
You can specify a target from your configuration by passing its name as an argument.
$ sevp google_cloud
$ sevp my_custom_var$ sevp listThis command lists all available targets defined in your configuration.
$ sevp view aws
$ sevp view google_cloud
$ sevp view my_custom_varThis command displays the configuration for a specific target, including the target_var and its possible_values.
SEVP uses a configuration file to define environment variables and their possible values: $HOME/.config/sevp.toml
Here’s an example configuration:
# Here we specify which target to use when using SEVP without any argument
default = "aws"
# ======================================================================
# External Config Selectors
#
# Currently the following targets support reading external settings:
# - aws: source settings from ~/.aws/config for AWS_PROFILE
# - docker-context: source settings from ~/.docker/contexts/meta dir
# - tfenv: source settings from ~/.tfenv/versions dir
# - goenv: source settings from ~/.goenv/versions dir
# ======================================================================
[aws]
external_config = false # true -> read profiles from ~/.aws/config
target_var = "AWS_PROFILE"
possible_values = ["prod1", "prod2"]
[docker-context]
external_config = true
target_var = "DOCKER_CONTEXT"
possible_values = ["default", "sample1", "sample2"]
[tfenv]
external_config = true
target_var = "TFENV_TERRAFORM_VERSION"
possible_values = ["1.0.0", "0.1.1"]
[goenv]
external_config = true
target_var = "GOENV_VERSION"
possible_values = ["1.18.0", "1.19.1"]
# ======================================================================
# User-defined Config Selectors
#
# The following are user-defined targets with manual configuration.
# ======================================================================
[google_cloud]
target_var = "GOOGLE_CLOUD_PROJECT"
possible_values = ["proj1", "proj2", "proj3"]
[some_var]
target_var = "MY_CUSTOM_ENV_VAR"
possible_values = ["val1", "val2"]External Config Providers allow SEVP to dynamically fetch values from external configuration files or directories. This is useful for tools like AWS CLI or Docker.
-
AWS
- Reads profiles from
~/.aws/config. - Automatically sets the
AWS_PROFILEenvironment variable. - Enable by setting
external_config = truein the[aws]section.
- Reads profiles from
-
Docker Context
- Reads contexts from
~/.docker/contexts/meta. - Automatically sets the
DOCKER_CONTEXTenvironment variable. - Enable by setting
external_config = truein the[docker-context]section.
- Reads contexts from
-
tfenv
- Support for https://github.com/tfutils/tfenv.
- Reads versions from
~/.tfenv/versions. - Automatically sets the
TFENV_TERRAFORM_VERSIONenvironment variable. - Enable by setting
external_config = truein the[tfenv]section.
-
goenv
- Support for https://github.com/go-nv/goenv.
- Reads Go versions from
~/.goenv/versions. - Automatically sets the
GOENV_VERSIONenvironment variable. - Enable by setting
external_config = truein the[goenv]section.
- When
external_config = true, SEVP ignores thepossible_valuesfield and dynamically fetches values from the external configuration. - This ensures SEVP stays in sync with changes made outside the tool.
[aws]
external_config = true
target_var = "AWS_PROFILE"
[docker-context]
external_config = true
target_var = "DOCKER_CONTEXT"
[tfenv]
external_config = true
target_var = "TFENV_TERRAFORM_VERSION"
[goenv]
external_config = true
target_var = "GOENV_VERSION"-
Tap the repository:
$ brew tap masamerc/sevp https://github.com/masamerc/sevp.git
-
Install:
$ brew install sevp
-
Add the shellhook to your shell configuration (
.zshrc/.bashrc):eval "$(sevp init <shell>)"
-
Run the one-liner:
$ curl -sSL https://raw.githubusercontent.com/masamerc/sevp/main/scripts/install.sh | bash -
Add the shellhook to your shell configuration (
.zshrc/.bashrc):eval "$(sevp init <shell>)"
-
Install using
go:$ go install github.com/masamerc/sevp@latest
-
Add the shellhook to your shell configuration (
.zshrc/.bashrc):eval "$(sevp init <shell>)"
-
Clone the repository:
$ git clone https://github.com/masamerc/sevp.git $ cd sevp -
Build and install (requires Taskfile):
$ task install
-
Add the shellhook to your shell configuration (
.zshrc/.bashrc):eval "$(sevp init <shell>)"
SEVP may conflict with tools like direnv since both rely on shell hooks. The order of evaluation determines which tool takes precedence.
-
SEVP takes precedence
Add SEVP afterdirenvin your shell configuration:eval "$(direnv hook zsh)" eval "$(sevp init zsh)"
-
direnvtakes precedence
Adddirenvafter SEVP:eval "$(sevp init zsh)" eval "$(direnv hook zsh)"
Contributions are welcome! Please see CONTRIBUTING for guidelines.



