Quantcast
Channel: CodeSection,代码区,Linux操作系统:Ubuntu_Centos_Debian - CodeSec
Viewing all articles
Browse latest Browse all 11063

direnv ― Unclutter your .profile

$
0
0

Many of my projects need specific environment variables to run. Usually I have a export.sh script that I source when I cd into the directory.

There’s a better way, which I highly recommend: direnv .

direnv is an environment switcher for the shell. It knows how to hook into bash, zsh, tcsh and fish shell to load or unload environment variables depending on the current directory. This allows project-specific environment variables without cluttering the “~/.profile” file.

Before each prompt, direnv checks for the existence of a “.envrc” file in the current and parent directories. If the file exists (and is authorized), it is loaded into a bash sub-shell and all exported variables are then captured by direnv and then made available to the current shell.


Viewing all articles
Browse latest Browse all 11063

Trending Articles