Last active
August 25, 2016 19:15
-
-
Save jkdba/ed65d0516b479af85f612b041488e2fb to your computer and use it in GitHub Desktop.
Updated PowerShell Console Window Title to Last Command and Current Path
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
## Use PowerShell Engine Event (OnIdle) to Update the PowerShell | |
## Console Window's Title to have the current path and last command executed. | |
## For this to work Nicely add it to your PowerShell Profile. | |
## Subscribe to PowerShell.OnIdle Event | |
## Out to null to hide Register-EngineEvent output | |
$null = Register-EngineEvent PowerShell.OnIdle -Action { | |
## Get Last Command ran from history | |
$LastCommand = Get-History | Sort-Object -Property Id -Descending | Select-Object -First 1 -exp CommandLine | |
## Updated the console window's title to have the path and command. | |
$host.ui.RawUI.WindowTitle = "$pwd> $LastCommand" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment