Home

Awesome

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.

This extension adds direnv support to Visual Studio Code by loading environment variables for the workspace root.

Features

Custom Environment

This extension automatically loads the custom environment direnv provides for the workspace. If the corresponding .envrc file is not allowed yet it provides the option to allow or view and then allow the file. When any files watches by direnv are modified the extension automatically reloads the environment.

The custom environment is available in integrated terminals, in custom tasks of type shell, and in environment variable substitutions (${env:VAR})

Only allow .envrc files from sources you trust since direnv executes arbitrary shell script.

Commands

Status Item

The extension displays a status icon that indicates whether it is currently working or has succeeded or failed.

Clicking the status item will also reload the custom environment.

Requirements

This extension requires direnv to be installed. We also recommend hooking direnv into your shell.

Known Issues

Custom tasks with type process don't pick up on the modified environment. Several task provider extensions provide these kinds of tasks.

When direnv unsets an environment variable then in the terminal it will be set to empty (what POSIX calls null). VSCode does not provide API to unset environment variables for the terminal. The difference between null and unset variables is mostly academic but some programs insist on treating them distinctly.

direnv executes arbitrary shell scripts so this extension requires trusted workspaces.

Acknowledgements

The logo is copyright 2015 Peter Waller and was created as the direnv logo.