Skip to content

Instantly share code, notes, and snippets.

@gabriel-vanca
Last active January 23, 2024 03:02
Show Gist options
  • Save gabriel-vanca/38326aff0db80fd96d14646af3531d4e to your computer and use it in GitHub Desktop.
Save gabriel-vanca/38326aff0db80fd96d14646af3531d4e to your computer and use it in GitHub Desktop.
Refreshing PowerShell Terminal
Write-Host "Refreshing terminal"
.$PROFILE
# ($NULL -eq $IsWindows) checks for Windows Sandbox enviroment
if($IsWindows -or ($NULL -eq $IsWindows)) {
# Expected path of the choco.exe file.
$chocoInstallPath = "$Env:ProgramData/chocolatey/choco.exe"
if(Test-Path -path $chocoInstallPath) {
# Make `refreshenv` available right away, by defining the $env:ChocolateyInstall
# variable and importing the Chocolatey profile module.
$env:ChocolateyInstall = Convert-Path "$((Get-Command choco).Path)\..\.."
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
Update-SessionEnvironment
refreshenv
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment