Skip to content

Instance-based window titles #19592

@God-damnit-all

Description

@God-damnit-all

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions