-
-
Save yatima1460/5e82729d6ed9c4298f9a9a9a2afd1553 to your computer and use it in GitHub Desktop.
chocolatey RefreshEnv for bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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