Envyman is a Bash script that helps you manage environment variable configurations easily. It allows you to add, load, unload, and list configuration files, configure where you want to store your configurations and track active configurations.
- Create configuration files containing a set
name=value
environment variables that are loaded inside any terminal session. - Start using the environment variables by specifying what configuration file you you want to load.
- Stop using the environment variable configuration at any time.
- Configure the root path where your configuration files are stored, moving any files inside the previous directory to the new one.
- List all configuration files in the root path.
- Check the last loaded configuration file, echoing it's full path and if it is active or not by verifying if the values of the variables defined in the file are correclty loaded into the system.
- Reinstall Envyman. If you made any changes to the script, you can imediatelly apply them by the install command.
- Uninstall Envyman, removing any modifications made to the system by the original install command and also removing your configuration files if you want to.
Let's say you want to access the values of URL
, USERNAME
and PASSWORD
from within a project that loads environment variables:
spring.datasource.url=${URL}
spring.datasource.username=${USERNAME}
spring.datasource.password=${PASSWORD}
envyman add myConfigFile URL=localhost USERNAME=paulo PASSWORD=granthon
- Result: This will create the
myConfigFile.sh
inside the current envyman root (default:~/envyman/
):
~/envyman/myConfigFile.sh
:
URL=localhost
USERNAME=paulo
PASSWORD=granthon
envyman start myConfigFile
- Result: Now the variables
URL
,USERNAME
andPASSWORD
are accessible to your project and will be populated at runtime with the values insidemyconfigfile
envyman start myOtherConfig
- An Unix system such as Linux or macOS
- Bash (version 4 or above)
-
Run this on any terminal of your choice to imediatelly clone and install Envyman:
git clone https://github.com/paulo-granthon/envyman.git chmod +x envyman/envyman envyman/envyman install
-
Clone the Envyman repository:
git clone https://github.com/paulo-granthon/envyman.git
-
Move into the Envyman directory:
cd envyman
-
Make the script executable:
chmod +x envyman
-
Install Envyman:
./envyman install
-
Verify the installation by running the following command:
envyman
Envyman supports the following commands:
-
add
: Add environment variable configurationenvyman add [config_file] [VAR1=VALUE1 VAR2=VALUE2 ...]
- The file will be created inside the current envyman root. You can also specify subdirectories.
- Example:
envyman add sub/dir/config_file ...
-
start
: Start using the environment variable configurationenvyman start [config_file]
- Note: If you created your file in a subdirectory inside the root, you'll need to specify it with the
start
command. - Example:
envyman start sub/dir/config_file
- Note: If you created your file in a subdirectory inside the root, you'll need to specify it with the
-
ls
: List all configuration files in the root pathenvyman ls
- Each line represents what you would specify as an argument for
envyman start
if you want to load that file, in other words, the path starting at the current envyman root and without the.sh
file extension at the end.
- Each line represents what you would specify as an argument for
-
check
: Check the last loaded configuration and echo loaded fileenvyman check
- This will echo the name of the last file that you loaded and also an "active" or "inactive" status depending on if the variables of the file have their values correctly loaded into the current terminal session.
-
stop
: Stop using the environment variable configurationenvyman stop
-
root
: Set the root path for configuration filesenvyman root [path]
-
groot
: Echo the current root pathenvyman groot
-
install
: Install Envymanenvyman install
-
uninstall
: Uninstall Envymanenvyman uninstall
Envyman was born out of a personal need to address a specific challenge I encountered while collaborating on a team project using Spring Boot JPA. As the sole user of NeoVim (and Arch Linux by the way), I lacked a convenient IDE solution for managing local environment variables like Eclipse offered. I didn't want to abruptly switch to Eclipse or resort to hardcoding the database URL, username, and password in either the project's application.properties
file (to avoid dealing with adding it to .gitignore since the file follows an specific template, or the risk of inadvertently exposing sensitive data on GitHub) or my machine's .bashrc file, which would require cleanup afterward. In response, I conceived the idea of creating an environment variable manager, Envyman, as a more robust solution to this issue. It provides a straightforward command to create sets of environment variables that can be easily loaded, allowing me to work on different projects with distinct variable configurations. When no longer needed, these configurations can be easily removed.
This project is licensed under the MIT License.
Contributions are welcome! If you find any issues or have suggestions, please open an issue or a pull request on the Envyman repository.