Skip to content

Bash based CLI tool for managing Environment Variables on Unix systems. Allows you to easily create multiple configuration files containing a set of environment variables to activate as you wish.

License

Notifications You must be signed in to change notification settings

paulo-granthon/envyman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Envyman

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.

Features

  • 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.

Getting Started

Example workflow

Let's say you want to access the values of URL, USERNAME and PASSWORD from within a project that loads environment variables:

Example Spring project application.properties:

spring.datasource.url=${URL}
spring.datasource.username=${USERNAME}
spring.datasource.password=${PASSWORD}

Create a configuration file for this project:

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

Load the variables:

envyman start myConfigFile
  • Result: Now the variables URL, USERNAME and PASSWORD are accessible to your project and will be populated at runtime with the values inside myconfigfile

"I'm working on another project and the environment variables I need are different"

envyman start myOtherConfig

Installation

Prerequisites

  • An Unix system such as Linux or macOS
  • Bash (version 4 or above)

Option A: TL;DR

  1. 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

Option B: To install Envyman, you can follow these steps:

  1. Clone the Envyman repository:

    git clone https://github.com/paulo-granthon/envyman.git
  2. Move into the Envyman directory:

    cd envyman
  3. Make the script executable:

    chmod +x envyman
  4. Install Envyman:

    ./envyman install
  5. Verify the installation by running the following command:

    envyman

Usage

Envyman supports the following commands:

  • add: Add environment variable configuration

    envyman 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 configuration

    envyman 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
  • ls: List all configuration files in the root path

    envyman 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.
  • check: Check the last loaded configuration and echo loaded file

    envyman 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 configuration

    envyman stop
  • root: Set the root path for configuration files

    envyman root [path]
  • groot: Echo the current root path

    envyman groot
  • install: Install Envyman

    envyman install
  • uninstall: Uninstall Envyman

    envyman uninstall

Story Time

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.

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! If you find any issues or have suggestions, please open an issue or a pull request on the Envyman repository.

About

Bash based CLI tool for managing Environment Variables on Unix systems. Allows you to easily create multiple configuration files containing a set of environment variables to activate as you wish.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Languages