Skip to content

Instantly share code, notes, and snippets.

@jkdba
Last active August 25, 2016 19:15
Show Gist options
  • Save jkdba/ed65d0516b479af85f612b041488e2fb to your computer and use it in GitHub Desktop.
Save jkdba/ed65d0516b479af85f612b041488e2fb to your computer and use it in GitHub Desktop.
Updated PowerShell Console Window Title to Last Command and Current Path
## 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