Last active
August 29, 2015 14:18
-
-
Save analogrelay/e8c55515f4d940314341 to your computer and use it in GitHub Desktop.
Get the active DNX and put it on your prompt
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
| # If 'dnvm' is present, this code writes " ([activednx])" to the host, where [activednx] is the | |
| # active DNX name. If 'dnvm' is not present, this writes nothing. | |
| # If we have dnvm, use it to determine the active DNX | |
| if(Get-Command dnvm -ErrorAction SilentlyContinue) { | |
| $activeDnx = dnvm list -passthru | where { $_.Active } | |
| if($activeDnx) { | |
| Write-Host " (" -nonewline -ForegroundColor ([ConsoleColor]::Yellow) | |
| Write-Host "dnx-$($activeDnx.Runtime)-win-$($activeDnx.Architecture).$($activeDnx.Version)" -nonewline -ForegroundColor ([ConsoleColor]::Cyan) | |
| Write-Host ")" -nonewline -ForegroundColor ([ConsoleColor]::Yellow) | |
| } | |
| } |
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 global:prompt { | |
| $realLASTEXITCODE = $LASTEXITCODE | |
| # Reset color, which can be messed up by Enable-GitColors | |
| if($GitPromptSettings.DefaultForegroundColor) { | |
| $Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor | |
| } | |
| Write-Host $pwd -nonewline -ForegroundColor ([ConsoleColor]::Yellow) | |
| # If we have dnvm, use it to determine the active DNX | |
| if(Get-Command dnvm -ErrorAction SilentlyContinue) { | |
| $activeDnx = dnvm list -passthru | where { $_.Active } | |
| if($activeDnx) { | |
| Write-Host " (" -nonewline -ForegroundColor ([ConsoleColor]::Yellow) | |
| Write-Host "dnx-$($activeDnx.Runtime)-win-$($activeDnx.Architecture).$($activeDnx.Version)" -nonewline -ForegroundColor ([ConsoleColor]::Cyan) | |
| Write-Host ")" -nonewline -ForegroundColor ([ConsoleColor]::Yellow) | |
| } | |
| } | |
| if(Get-Command Write-VcsStatus -ErrorAction SilentlyContinue) { | |
| Write-VcsStatus | |
| } | |
| Write-Host | |
| Write-Host "ps1 #" -nonewline -ForegroundColor ([ConsoleColor]::Green) | |
| $LASTEXITCODE = $realLASTEXITCODE | |
| $Host.UI.RawUI.WindowTitle = $pwd | |
| return " " | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment