Skip to content

Instantly share code, notes, and snippets.

@LeeHolmes
Created March 16, 2019 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LeeHolmes/710e06d89a372ec29158c6ddbc114e8f to your computer and use it in GitHub Desktop.
Save LeeHolmes/710e06d89a372ec29158c6ddbc114e8f to your computer and use it in GitHub Desktop.
My PowerShell Profile
$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