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.
- 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
pip install envprofile# Clone the repository
git clone https://github.com/yourusername/envprofile.git
cd envprofile
# Install the package
pip install -e .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# 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# 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# Method 1: Using the shell function defined during installation
use-env dev
# Method 2: Direct evaluation
eval $(envprofile load prod)# After loading a profile, you can verify the environment variables are set
echo $DB_HOST
echo $API_KEYAll 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"
}
}You can use EnvProfile to generate environment files for Docker:
# Generate a .env file for docker-compose
envprofile load dev > .envCreate project-specific profiles by using prefixes:
# Create profiles for different projects
envprofile create project1-dev
envprofile create project1-prod
envprofile create project2-devIssue: 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.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by various environment management tools like direnv and autoenv
- Thanks to all contributors