Skip to content

Instantly share code, notes, and snippets.

@analogrelay
Last active August 29, 2015 14:18
Show Gist options
  • Save analogrelay/e8c55515f4d940314341 to your computer and use it in GitHub Desktop.
Save analogrelay/e8c55515f4d940314341 to your computer and use it in GitHub Desktop.
Get the active DNX and put it on your prompt
# 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)
}
}
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