direnv
direnv is an extension for your shell. It augments existing shells with a new feature that can load and unload environment variables depending on the current directory. [1]
Documentation
- man 1 'direnv' [EN]
- man 1 'direnv-stdlib' [EN]
- man 1 'direnv.toml' [EN]
Syntax
direnv COMMAND [ARGUMENTS ...]
Sub-commands
- allow [PATH_TO_RC], grant [PATH_TO_RC], permit [PATH_TO_RC]
- Grants direnv permission to load the given .envrc or .env file.
- block [PATH_TO_RC], deny [PATH_TO_RC], disallow [PATH_TO_RC], revoke [PATH_TO_RC]
- Revokes the authorization of a given .envrc or .env file.
- hook SHELL
- Used to setup the shell hook.
- reload
- Triggers an env reload.
Examples
- Change the default editor in the ~/tmp directory
- Create an .envrc file
vi "${HOME}/tmp/.envrc"
#!/bin/bash export EDITOR='nano'
- Change the directory
cd "${HOME}/tmp"
- Output
direnv: error /Users/leuenbe/tmp/.envrc is blocked. Run `direnv allow` to approve its content
- Allow the .envrc file to be executed
direnv allow
- Output
direnv: loading ~/tmp/.envrc direnv: export ~EDITOR
References
- ↑ Project contributors. "direnv - unclutter your .profile." direnv project. https://direnv.net/ (accessed 24.01.2024)