Skip to content
/ envy Public

Load environment variables from YAML and export them to your shell

License

Notifications You must be signed in to change notification settings

ricoveri/envy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

envy

A simple environment variable exporter that loads variables from a YAML configuration file and outputs them as shell export statements.

Overview

envy reads a YAML file containing environment variable definitions and outputs them as shell-compatible export statements. This makes it easy to manage and load environment variables across different shell sessions.

Features

  • 📝 YAML Configuration: Define environment variables in a simple YAML file
  • 🔗 Array Support: Automatically converts arrays to colon-separated strings (perfect for PATH-like variables)
  • 🏠 Home Directory Integration: Reads configuration from ~/.envyrc.yaml by default
  • 📂 Custom Config Path: Specify a custom configuration file path via command-line argument
  • 🚀 Shell Integration Ready: Outputs standard export statements for easy sourcing

Installation

From Source

git clone https://github.com/ricoveri/envy.git
cd envy
cargo build --release

The binary will be available at target/release/envy.

Usage

  1. Create a .envyrc.yaml file in your home directory:
# Simple string values
MY_VAR: "hello"
DATABASE_URL: "postgres://localhost:5432/mydb"

# Array values (converted to colon-separated strings)
PATH:
  - "/usr/local/bin"
  - "/usr/bin"
  - "/bin"

CUSTOM_PATH:
  - "/opt/myapp/bin"
  - "/opt/tools/bin"
  1. Run envy to generate export statements:
# Use default config file (~/.envyrc.yaml)
envy

# Or specify a custom config file
envy path/to/config.yaml

Output:

export MY_VAR="hello"
export DATABASE_URL="postgres://localhost:5432/mydb"
export PATH="/usr/local/bin:/usr/bin:/bin"
export CUSTOM_PATH="/opt/myapp/bin:/opt/tools/bin"
  1. Source the output in your shell:

Bash/Zsh:

eval "$(envy)"

Configuration File Format

The configuration file uses YAML format and supports two types of values:

String Values

VARIABLE_NAME: "value"

Array Values (for PATH-like variables)

VARIABLE_NAME:
  - "value1"
  - "value2"
  - "value3"

Arrays are automatically converted to colon-separated strings (e.g., value1:value2:value3).

Command-Line Usage

envy [CONFIG_FILE]

Arguments

  • CONFIG_FILE (optional): Path to a YAML configuration file. If not provided, defaults to ~/.envyrc.yaml

Options

  • --help: Display help information
  • --version: Display version information

Examples

# Use default config
envy

# Use custom config file
envy ./my-env.yaml
envy /etc/myapp/env.yaml

# Get help
envy --help

# Check version
envy --version

Integration with Shell

Add the following to your shell's configuration file:

Bash (~/.bashrc or ~/.bash_profile):

if command -v envy &> /dev/null; then
    eval "$(envy)"
fi

Zsh (~/.zshrc):

if command -v envy &> /dev/null; then
    eval "$(envy)"
fi

Development

Prerequisites

  • Rust 2024 edition or later
  • Cargo

Building

cargo build

Running

cargo run

Testing

cargo test

Dependencies

  • clap - Command-line argument parser
  • dirs - Platform-specific standard locations
  • yaml-rust - YAML parser

License

Copyright (c) 2025 Alejandro Ricoveri

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

Load environment variables from YAML and export them to your shell

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages