Skip to content

Instantly share code, notes, and snippets.

@Stephanevg
Created June 30, 2017 07:41
Show Gist options
  • Save Stephanevg/c91e8d674da8805bab6fc2c8133f60d5 to your computer and use it in GitHub Desktop.
Save Stephanevg/c91e8d674da8805bab6fc2c8133f60d5 to your computer and use it in GitHub Desktop.
windows powershell profile
function prompt
{
# The at sign creates an array in case only one history item exists.
$history = @(get-history)
if($history.Count -gt 0)
{
$lastItem = $history[$history.Count - 1]
$lastId = $lastItem.Id
}
$nextCommand = $lastId + 1
$currentDirectory = get-location
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = [Security.Principal.WindowsPrincipal] $identity
write-host "[" -NoNewline
if($principal.IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
write-host "A" -NoNewline -ForegroundColor Red
}else{
write-host "N" -NoNewline -ForegroundColor Yellow
}
write-host -NoNewline "][$nextCommand] $currentDirectory >"
return " "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment