Last active
February 4, 2022 07:01
-
-
Save jayvdb/1daf8c60e20d64024f51ec333f5ce806 to your computer and use it in GitHub Desktop.
chocolatey RefreshEnv for bash
This file contains 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