direnv-vscode icon indicating copy to clipboard operation
direnv-vscode copied to clipboard

"The following extensions want to relaunch the terminal to contribute to its environment: direnv"

Open Nezteb opened this issue 10 months ago • 5 comments

I frequently get prompted by VS Code to reload the direnv extension with a message like so:

screenshot_2023-10-19_at_19 08 29@2x

OS: macOS 13.6 (M2) Editor: VS Code 1.84.0-insider Extension: v0.15.2 Shell env: Nushell 0.85.0

My Nushell config:

# ~/.config/nushell/config.nu

# ...
$env.config = {
    # ...
    hooks: {
        # ...
        env_change: {
            # https://direnv.net/docs/hook.html#nushell
            PWD: { ||
                if (which direnv | is-empty) {
                    return
                }
            
                direnv export json | from json | default {} | load-env
            }
        }
        # ...
    }
    # ...
}
# ...

Nezteb avatar Oct 19 '23 19:10 Nezteb