Skip to content

Instantly share code, notes, and snippets.

@ziggythehamster
Created August 6, 2015 22:27
Show Gist options
  • Save ziggythehamster/a272458049b8e763d507 to your computer and use it in GitHub Desktop.
Save ziggythehamster/a272458049b8e763d507 to your computer and use it in GitHub Desktop.
Bashlike PowerShell Prompt
function prompt {
$realLASTEXITCODE = $LASTEXITCODE
# Reset color, which can be messed up by Enable-GitColors
$Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal( [Security.Principal.WindowsIdentity]::GetCurrent() )
& {
if ($currentPrincipal.IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator ))
{
Write-Host($env:username) -f red -nonewline
Write-Host("@") -f red -nonewline
Write-Host($env:computername) -f red -nonewline
Write-Host(":") -nonewline
Write-Host($pwd.ProviderPath) -f blue -nonewline
Write-VcsStatus
Write-Host('#') -nonewline
} else {
Write-Host($env:username) -f green -nonewline
Write-Host("@") -f green -nonewline
Write-Host($env:computername) -f green -nonewline
Write-Host(":") -nonewline
Write-Host($pwd.ProviderPath) -f blue -nonewline
Write-VcsStatus
Write-Host('$') -nonewline
}
}
$global:LASTEXITCODE = $realLASTEXITCODE
return " "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment