-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Summary of the new feature
Currently, if you change the window title via $Host.UI.RawUI.WindowTitle, that change is persistent and will remain that way even after a script complete and, in cases where another shell started PowerShell, even after PowerShell is closed.
It would be better if there was a way to change the window title that only lasted until the end of the environment that the window title change was invoked.
Proposed implementation
I think it would make the most sense to tie this to an automatic variable - let's say $PSWindowTitle. It would start off as $null. If a function invoked a window title change, it would last only until the end of the function unless the variable was set through the global scope, e.g. $global:PSWindowTitle, then it would last until the end of the environment that called the function.
$Host.UI.RawUI.WindowTitle would still be an option and would function the same way it currently does, but $PSWindowTitle overrides it whenever $PSWindowTitle is not $null.
This implementation also has the bonus of being backward-compatible in the sense that if this variable is changed by an older version of PowerShell without this feature, nothing happens, rather than something breaking.