I have the following in my $profile:
Import-Module posh-git
$GitPromptSettings.WindowTitle = $null
If I start a script that changes $host.UI.RawUI.WindowTitle directly then this still gets overwritten with $PreviousWindowTitle that was initialised with the text from when the PowerShell window was started. I would like my script to be able to change the title and have the same effect regardless of whether posh-git is loaded.
I know there has been some discussion about this before in previous issues - but could it be considered that a setting could be added to $GitPromptSettings to disable any update of $host.UI.RawUI.WindowTitle?
Maybe this could also be added as a parameter when the module starts so that the WindowTitle never gets updated or changed by the module (and hence would not need to be reverted to $PreviousWindowTitle).
It seems to me that setting $GitPromptSettings.WindowTitle to $null/$false should completely disable any window title fiddling.
Module parameters are a rather poor experience, so I'm more inclined to defer $WindowTitleSupported initialization until the first prompt runs (and only initialize at all if $GitPromptSettings.WindowTitle isn't $null/$false at that time). Does that seem reasonable?
@dahlbyk - Yes, agree that the window title should be left alone if $GitPromptSettings.WindowTitle is $null/$false
It seems to me that setting $GitPromptSettings.WindowTitle to $null/$false should completely disable any window title fiddling.
So the issue is that if someone disables $GitPromptSettings.WindowTitle interactively, we were using $PreviousWindowTitle to set the Window title back to the original "Windows PowerShell" title. Unfortunately, as long as $GitPromptSettings.WindowTitle is $null, we set the WindowTitle to $PreviousWindowTitle (which is better named OriginalWindowTitle or something like that). Perhaps we just punt on this admittedly corner case scenario of a user interactively disabling the WindowTitle? If if someone does this, their WindowTitle will be stuck to what it was when they disabled it.
Perhaps we just punt on this admittedly corner case scenario of a user interactively disabling the WindowTitle? If if someone does this, their WindowTitle will be stuck to what it was when they disabled it.
I'm fine with this. The primary use case here is setting a personal preference in $PROFILE.
Sounds good. I'll submit a PR for this tonight.
@dahlbyk Thanks!
Most helpful comment
Sounds good. I'll submit a PR for this tonight.