Skip to content

Instantly share code, notes, and snippets.

@yatima1460
Forked from jayvdb/RefreshEnv.sh
Created July 22, 2019 03:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yatima1460/5e82729d6ed9c4298f9a9a9a2afd1553 to your computer and use it in GitHub Desktop.
Save yatima1460/5e82729d6ed9c4298f9a9a9a2afd1553 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