-
-
Save sgeto/5e781bd34071a3a331a83f8c248334ee to your computer and use it in GitHub Desktop.
Powershell init script to include vcvarsall.bat and set the window title.
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
| # Load posh-git example profile | |
| . '~\Documents\WindowsPowerShell\Modules\posh-git\profile.example.ps1' | |
| $GitPromptSettings.EnableFileStatus = $false | |
| $global:CurrentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent() | |
| function Prompt() { | |
| Write-Host ("PS " + $(get-location) ) -nonewline -foregroundcolor Magenta | |
| Write-VcsStatus | |
| Write-Host ">" -nonewline -foregroundcolor Magenta | |
| return " " | |
| } | |
| $tempFile = [IO.Path]::GetTempFileName() | |
| ## Store the output of cmd.exe. We also ask cmd.exe to output | |
| ## the environment table after the batch file completes | |
| cmd /c " `"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat`" && set > `"$tempFile`" " | |
| ## Go through the environment variables in the temp file. | |
| ## For each of them, set the variable in our local environment. | |
| Get-Content $tempFile | Foreach-Object { | |
| if($_ -match "^(.*?)=(.*)$") | |
| { | |
| Set-Content "env:\$($matches[1])" $matches[2] | |
| } | |
| } | |
| Remove-Item $tempFile | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment