Skip to content

Instantly share code, notes, and snippets.

@jayvdb
Last active February 4, 2022 07:01
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jayvdb/1daf8c60e20d64024f51ec333f5ce806 to your computer and use it in GitHub Desktop.
Save jayvdb/1daf8c60e20d64024f51ec333f5ce806 to your computer and use it in GitHub Desktop.
chocolatey RefreshEnv for bash
function refreshenv
{
powershell -NonInteractive - <<\EOF
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
Update-SessionEnvironment
# Round brackets in variable names cause problems with bash
Get-ChildItem env:* | %{
if (!($_.Name.Contains('('))) {
$value = $_.Value
if ($_.Name -eq 'PATH') {
$value = $value -replace ';',':'
}
Write-Output ("export " + $_.Name + "='" + $value + "'")
}
} | Out-File -Encoding ascii $env:TEMP\refreshenv.sh
EOF
source "$TEMP/refreshenv.sh"
}
alias RefreshEnv=refreshenv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment