Created
June 30, 2017 07:41
-
-
Save Stephanevg/c91e8d674da8805bab6fc2c8133f60d5 to your computer and use it in GitHub Desktop.
windows powershell profile
This file contains hidden or 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 | |
{ | |
# 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