28 lines
981 B
PowerShell
28 lines
981 B
PowerShell
# Customize PowerShell prompt.
|
|
function Prompt {
|
|
$exitCode = $LastExitCode
|
|
# Line one
|
|
Get-Date -Format "HH:mm:ss " | Write-Host -ForegroundColor DarkGray -NoNewline
|
|
$location = (Get-Location).Path
|
|
if ($location.StartsWith($env:USERPROFILE)) {
|
|
$location = $location.Replace($env:USERPROFILE, "~")
|
|
}
|
|
$location | Write-Host -ForegroundColor DarkCyan -NoNewline
|
|
if ($exitCode -ne 0) {
|
|
" $exitCode" | Write-Host -ForegroundColor DarkRed -NoNewline
|
|
}
|
|
& $GitPromptScriptBlock | Write-Host -NoNewline
|
|
Write-Host
|
|
# Line two
|
|
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
|
|
$principal = [Security.Principal.WindowsPrincipal] $identity
|
|
$adminRole = [Security.Principal.WindowsBuiltInRole]::Administrator
|
|
$userName = $Env:USERNAME.ToLower()
|
|
if($principal.IsInRole($adminRole)) {
|
|
$userName | Write-Host -ForegroundColor DarkRed -NoNewline
|
|
} else {
|
|
$userName | Write-Host -ForegroundColor DarkGreen -NoNewline
|
|
}
|
|
return ' '
|
|
}
|