Created
March 16, 2019 22:51
-
-
Save LeeHolmes/710e06d89a372ec29158c6ddbc114e8f to your computer and use it in GitHub Desktop.
My PowerShell Profile
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
$historyItem = Get-History -Count 1 | |
$id = 1 | |
if($historyItem) | |
{ | |
$id = $historyItem.Id + 1 | |
## Check if the last command took a long time | |
if(($historyItem.EndExecutionTime - $historyItem.StartExecutionTime).TotalSeconds -gt 3) | |
{ | |
[Console]::Beep(500,200) | |
} | |
} | |
$version = (gps -id $pid).Modules[0].FileVersionInfo.FileVersion | |
## Get the nested prompt extra | |
if($NestedPromptLevel -gt 0) | |
{ | |
$nestedPromptExtra = "[$NestedPromptLevel]" | |
} | |
f(-not (test-path variable:\staticWindowTitle)) { $SCRIPT:staticWindowTitle = "" } | |
f(-not (test-path variable:\staticWindowExtra)) { $SCRIPT:staticWindowExtra = "" } | |
$identity = [Security.Principal.WindowsIdentity]::GetCurrent() | |
$principal = [Security.Principal.WindowsPrincipal] $identity | |
$adminExtra = $null | |
if($principal.IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) | |
{ | |
$adminExtra = "Administrator: " | |
} | |
if(-not (Test-Path variable:\nestedPromptExtra)) { $nestedPromptExtra = "" } | |
Write-Host -F DarkGray "`n[$(get-location)]" | |
Write-Host -NoNewLine "PS:$id$nestedPromptExtra >" | |
if(-not $($staticWindowTitle -eq "true")) | |
{ | |
if(-not $($staticWindowExtra -eq $())) | |
{ | |
$host.UI.RawUI.WindowTitle = "$adminExtra$pwd [$version] $staticWindowExtra" | |
} | |
else | |
{ | |
$host.UI.RawUI.WindowTitle = "$adminExtra$pwd [$version]" | |
} | |
} | |
" " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment