Skip to content

Instantly share code, notes, and snippets.

@kilasuit kilasuit/sampleprompt.ps1
Last active Apr 5, 2019

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

commented Mar 12, 2019

Updated to include Posh-Git into the output and also add in a new line separation as below

image

@kilasuit

This comment has been minimized.

Copy link
Owner Author

commented Mar 15, 2019

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
You can’t perform that action at this time.