Created
August 6, 2015 22:27
-
-
Save ziggythehamster/a272458049b8e763d507 to your computer and use it in GitHub Desktop.
Bashlike PowerShell Prompt
This file contains 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 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