A plugin for profile.d that integrates direnv - a powerful environment switcher for the shell that loads and unloads environment variables depending on the current directory.
- Automatically installs and configures direnv
- Provides enhanced direnv functionality with additional commands:
use node
- Manages Node.js environments using nvmuse python
- Manages Python environments using pyenvuse dotenv
- Loads environment variables from .env filesuse aws_secret_env
- Loads environment variables from AWS Secrets Manageruse default
- Provides default directory configuration
- Includes smart dependency management for Node.js and Python projects
- Offers detailed logging and debugging capabilities
- Supports automatic environment switching when changing directories
- Add the following line to your
~/.profiledrc
:
PLUGINS=(
# ... your other plugins ...
https://github.com/jakubro/profile.d-direnv
)
- Run the installation commands:
profile.d-install
. ~/.bashrc
Create a .envrc
file in your project directory and use any of the provided commands. For example:
# .envrc
use node 18
use python 3.11.5
use dotenv
Then allow the direnv configuration:
direnv allow
# Use specific Node.js version
use node 18
# Use Node.js version from .nvmrc with custom root directory
use node --root=./src
# Use specific Python version
use python 3.11.5
# Additional options
use python --upgrade-pip
use python --write-requirements
use python --root=./src
# Load from .env file
use dotenv
# Load from specific file
use dotenv .env.local
# Load without overwriting existing variables
use dotenv --no-overwrite
# Load from AWS Secrets Manager
use aws_secret_env production/mysql
use aws_secret_env staging/redis --profile=staging --region=us-east-1
# Load parent .envrc files and private configurations
use default
# Load as root configuration
use default root
The plugin:
- Installs direnv during the installation phase
- Sets up shell hooks for automatic environment loading/unloading
- Provides enhanced direnv functionality through custom commands
- Manages development environments and dependencies automatically
- Handles environment variables from various sources (files, AWS, etc.)
Optional tools based on usage:
- Node.js features require nvm
- Python features require pyenv
- AWS features require AWS CLI
If you would like to contribute to this project, please feel free to submit a pull request or open an issue for discussion.
MIT License - see the LICENSE file for details.