Last active
January 6, 2022 14:46
-
-
Save kilasuit/8f17db5a0825f3cdaa315385456e7f7e to your computer and use it in GitHub Desktop.
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 | |
{ | |
# Admin ? | |
if( ( | |
New-Object Security.Principal.WindowsPrincipal ( | |
[Security.Principal.WindowsIdentity]::GetCurrent()) | |
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) | |
{ | |
# Admin-mark in WindowTitle | |
$Host.UI.RawUI.WindowTitle = "[Admin] " + $Host.UI.RawUI.WindowTitlep | |
# Admin-mark on prompt | |
Write-Host "[" -nonewline -foregroundcolor DarkGray | |
Write-Host "Admin" -nonewline -foregroundcolor Red | |
Write-Host "] " -nonewline -foregroundcolor DarkGray | |
} | |
Write-Host "[" -NoNewline | |
Write-Host (Get-Date -Format "HH:mm:ss") -ForegroundColor Gray -NoNewline | |
Write-Host "] [" -NoNewline | |
Write-Host "$(((H)[-1].EndExecutionTime - (H)[-1].StartExecutionTime).Milliseconds) ms" -NoNewline -ForegroundColor Gray | |
Write-Host "]" -NoNewline | |
if(Get-Module Posh-git) {Write-VcsStatus; Write-host ''} | |
Write-Host "$($executionContext.SessionState.Path.CurrentLocation.ProviderPath)" -NoNewline | |
"> " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to include Posh-Git into the output and also add in a new line separation as below