about_set-env.help.txt
Set or unset environment variables in the context of a single command.
What is it? =========== * A command, `Set-Env`, similar to the unix `env` command which sets or unsets environment variables, executes a given command, then restores them to their original state: * Set-Env foo=bar { echo $env:foo } * Set-Env -u bat_theme -c { bat .\readme.md } * A [`CommandNotFoundAction`](https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.commandinvocationintrinsics.commandnotfoundaction?view=pscore-6.2.0) which enables a unix-like syntax for `Set-Env`: * BAT_THEME="TwoDark" bat .\readme.md * foo=bar baz=qux {node -e "['foo', 'baz'].forEach(x => console.log(process.env[x]))"} Install =========== From the [gallery](https://www.powershellgallery.com/packages/set-env/) ```sh Install-Module set-env Import-Module set-env # add to profile. e.g: Add-Content $PROFILE `n, 'Import-Module set-env' Add-Content $PROFILE 'Register-AutoSetEnv' Add-Content $PROFILE 'New-Alias env set-env' ``` |