-
Install Windows Subsystem for Linux (WSL) if not already installed:
- Open PowerShell as Administrator and run:
wsl --install
- Restart your computer if prompted.
- Open PowerShell as Administrator and run:
-
Open WSL (Linux terminal) and install
direnv
:- Once WSL is installed and set up, open a WSL terminal (e.g., Ubuntu) and run:
sudo apt update sudo apt install direnv
- Once WSL is installed and set up, open a WSL terminal (e.g., Ubuntu) and run:
-
Configure
direnv
in your shell (Bash, Zsh, etc.):- Add the following to your shell configuration file (e.g.,
~/.bashrc
for Bash or~/.zshrc
for Zsh):eval "$(direnv hook bash)" # or use "zsh" if using Zsh
- Reload the shell configuration:
source ~/.bashrc # or ~/.zshrc
- Add the following to your shell configuration file (e.g.,
-
Install
direnv
using Homebrew:- Open a terminal and run:
brew install direnv
- Open a terminal and run:
-
Configure
direnv
in your shell:- Add the following line to your shell configuration file (e.g.,
~/.bashrc
for Bash or~/.zshrc
for Zsh):eval "$(direnv hook bash)" # or "zsh" for Zsh
- Then reload the shell configuration:
source ~/.bashrc # or ~/.zshrc
- Add the following line to your shell configuration file (e.g.,
Once installed, you can verify by running:
direnv version
Let me know if you run into any issues with the installation!
To activate direnv
in a specific folder, follow these steps:
-
Navigate to the folder where you want to use
direnv
:cd /path/to/your/folder
-
Create an
.envrc
file in the folder and add any environment variables or commands you want to set:echo 'export OPEN_AI_KEY="Your Key"' > .envrc
-
Allow the
.envrc
file by running the following command:direnv allow
-
Now, every time you enter this folder,
direnv
will automatically load the environment variables and commands specified in.envrc
. If you make changes to.envrc
, rundirenv allow
again to apply them.
Let me know if you have any further questions about using direnv
!