direnv
Direnv is a command-line tool that helps manage environment variables in your shell session. It aims to make it easier to work with different project-specific environments by automatically loading and unloading environment variables as you navigate between directories.
Direnv works by placing a .envrc
file in your project directory. This file contains a set of environment variable assignments specific to that project. When you enter the directory, direnv will read the .envrc
file and set the environment variables defined within it. Conversely, when you leave the directory, direnv will unset those variables.
One of the main advantages of using direnv is that it allows you to keep your environment variable configurations separate and organized within your different project directories. This means you can have different sets of environment variables activated automatically as you switch between projects, ensuring that you have the correct configuration for each project without manual intervention.
Direnv also supports several features that make it more flexible and powerful. For example, you can define global environment variables that apply to all directories or specify certain files to be loaded or excluded when entering a directory. Additionally, direnv provides hooks to execute arbitrary commands on environment changes, allowing you to perform custom actions whenever you enter or leave a directory.
Overall, direnv provides a streamlined way to manage environment variables, making it easier to switch between different project environments and ensuring that your environment is correctly configured for each project.
List of commands for direnv:
-
direnv:tldr:4c375 direnv: Revoke the authorization to load the `.envrc` present in the current directory.$ direnv deny ${-}try on your machineexplain this command
-
direnv:tldr:7e9f1 direnv: Grant direnv permission to load the `.envrc` present in the current directory.$ direnv allow ${-}try on your machineexplain this command
-
direnv:tldr:7efa2 direnv: Trigger a reload of the environment.$ direnv reloadtry on your machineexplain this command
-
direnv:tldr:cae81 direnv: Print some debug status information.$ direnv statustry on your machineexplain this command
-
direnv:tldr:ddb24 direnv: Edit the `.envrc` file in the default text editor and reload the environment on exit.$ direnv edit ${-}try on your machineexplain this command