Skip to content

Instantly share code, notes, and snippets.

@kilasuit
Last active January 6, 2022 14:46
Show Gist options
  • Save kilasuit/8f17db5a0825f3cdaa315385456e7f7e to your computer and use it in GitHub Desktop.
Save kilasuit/8f17db5a0825f3cdaa315385456e7f7e to your computer and use it in GitHub Desktop.
Powershell prompt
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
"> "
}
@kilasuit
Copy link
Author

This update adds the following to the Prompt

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment