Skip to main content

Environment Variable Profile Manager

Project description

EnvProfile - Environment Variable Profile Manager

Python Tests PyPI version License: MIT

EnvProfile is a tool that lets you create and manage different sets of environment variables that you can easily load when needed. This is particularly useful for developers who work with different projects that require different environment configurations.

Features

  • Create multiple named environment profiles
  • Add, remove, and update environment variables in profiles
  • Load environment variables from profiles into your current shell
  • List available profiles and view their contents
  • Easy to use command-line interface

Installation

From PyPI (Recommended)

pip install envprofile

From Source

# Clone the repository
git clone https://github.com/yourusername/envprofile.git
cd envprofile

# Install the package
pip install -e .

Shell Integration

Add a shell function to your .bashrc, .zshrc, or equivalent shell configuration file:

# Add this to your shell configuration file
function use-env() {
    eval "$(envprofile load $1)"
}

Reload your shell configuration:

source ~/.bashrc  # or ~/.zshrc

Usage Examples

Creating Profiles

# Create a new profile for development environment
envprofile create dev

# Add environment variables to the profile
envprofile add dev DB_HOST localhost
envprofile add dev DB_PORT 5432
envprofile add dev API_KEY dev_api_key_123
envprofile add dev DEBUG true

# Create another profile for production
envprofile create prod
envprofile add prod DB_HOST production.example.com
envprofile add prod DB_PORT 5432
envprofile add prod API_KEY prod_api_key_456
envprofile add prod DEBUG false

Managing Profiles

# List all available profiles
envprofile list

# Show details of a specific profile
envprofile show dev

# Remove a variable from a profile
envprofile remove dev DEBUG

# Delete an entire profile
envprofile delete test

Loading Profiles

# Method 1: Using the shell function defined during installation
use-env dev

# Method 2: Direct evaluation
eval $(envprofile load prod)

Checking Active Environment Variables

# After loading a profile, you can verify the environment variables are set
echo $DB_HOST
echo $API_KEY

Configuration

All profiles are stored in a single JSON file at ~/.config/envprofile/profiles.json. The format is:

{
  "dev": {
    "DB_HOST": "localhost",
    "DB_PORT": "5432",
    "API_KEY": "dev_api_key_123"
  },
  "prod": {
    "DB_HOST": "production.example.com",
    "DB_PORT": "5432",
    "API_KEY": "prod_api_key_456"
  }
}

Advanced Usage

Using with Docker

You can use EnvProfile to generate environment files for Docker:

# Generate a .env file for docker-compose
envprofile load dev > .env

Using with Multiple Projects

Create project-specific profiles by using prefixes:

# Create profiles for different projects
envprofile create project1-dev
envprofile create project1-prod
envprofile create project2-dev

Troubleshooting

Common Issues

Issue: Changes to environment variables not appearing in the shell

Solution: Make sure you're using the eval command or the use-env function as described in the installation section.

Issue: Error "command not found: envprofile"

Solution: Ensure that the installation directory is in your PATH or install using pip.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Inspired by various environment management tools like direnv and autoenv
  • Thanks to all contributors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

envprofile-0.1.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

envprofile-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file envprofile-0.1.0.tar.gz.

File metadata

  • Download URL: envprofile-0.1.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for envprofile-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3220388d0bbc7c9db15122e6e8188e17350fa7503148a84839919c3a320a4815
MD5 722765728e638bba9ce8384f4e47aa85
BLAKE2b-256 36f55cffc21da75665ec470f98b138efcc36e8984d1838c77da06d2d6fe66945

See more details on using hashes here.

File details

Details for the file envprofile-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: envprofile-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for envprofile-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5dc2384f9eb03c3f3c2d18206f3dcef71054dea94d57ba0a2d92aec942f5b46
MD5 b77faaeebecbbae41c39a13671195036
BLAKE2b-256 fccd4048a6e7b9cb6fd5f06f6f56ee580620388e408964061b6f1b0b10ca91c6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page