I've had the following line in my PowerShell profile for years.
$GitPromptSettings.EnableWindowTitle = $true
After installing posh-git from the Gallery (and removing it from my User modules location), it no longer works! This appears on launching a new console.
The property 'EnableWindowTitle' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\anthony.mastrean\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:17 char:1
+ $GitPromptSettings.EnableWindowTitle = $true
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Can you double-check the version of posh-git you're running? What does Get-Module posh-git return? There is definitely a $GitPromptSettings.EnableWindowTitle in 0.7.3 but in v1.0.0-betax, the state of the current master branch, the property has been renamed to $GitPromptSettings.WindowTitle.
Also, what output do you get if you execute $GitPromptSettings?
Yeah, I double-checked; it's very confusing 😄
PS> get-module posh-git
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.7.3 posh-git {Add-PoshGitToProfile, Add-SshKey, Enable-GitColors, Expand-GitCommand...}
I seem to have access to all the vars once the shell is loaded up.
PS> $GitPromptSettings.EnableWindowTitle
posh~git ~
So is it possible you got the PropertyNotFound error because you tried to access it before the posh-git module loaded?
When are system modules loaded? I thought _before_ my user profile. Otherwise, what profile should I use for setting this var?
On May 22, 2018, at 6:18 PM, Keith Hill notifications@github.com wrote:
So is it possible you got the PropertyNotFound error because you tried to access it before the posh-git module loaded?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
Look in ~\Documents\WindowsPowerShell\profile.ps1 and make sure that you are accessing that property after the Import-Module posh-git statement. If this is not in profile.ps1, check in ~\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1.
I do not have a profile.ps1, just this:
PS> ls
Directory: C:\Users\anthony.mastrean\Documents\WindowsPowerShell
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 5/22/2018 6:04 PM 1380
Microsoft.PowerShell_profile.ps1
And I do not explicitly Import-Module on any of the modules I've
installed via the Gallery (since they're installed at the machine-level,
I'm under the impression they're imported automatically... and that's how
it seems to work, although I'm not certain of the lifecycle of machine vs.
user profile).
On Tue, May 22, 2018 at 7:21 PM Keith Hill notifications@github.com wrote:
Look in ~\Documents\WindowsPowerShellprofile.ps1 and make sure that you
are accessing that property after the Import-Module posh-git statement.
If this is not in profile.ps1, check in
~\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/dahlbyk/posh-git/issues/582#issuecomment-391171615,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AANS8siDrjczYlFJOZ8LHeW0PmI87y5Uks5t1J1vgaJpZM4UJdgM
.
Exports from system modules are automatically _available_, but they're not actually imported until you use a function from them. Since there's really nothing to "do" with posh-git other than import it, you'll want to add Import-Module posh-git to $PROFILE before you modify $GitPromptSettings.
Add-PoshGitToProfile can add it for you, but it will add the import at the end of your profile.
@AnthonyMastrean This is a profile Microsoft.PowerShell_profile.ps1 that applies only to the PowerShell console host. You might open that file up in ISE or VSCode to see what's in it.
Adding Import-Module posh-git to my User profile _before_ accessing
$GitPromptSettings did the trick! Sorry for the fuss, I thought the
module loading lifecycle would be more obvious :D
On Wed, May 23, 2018 at 12:10 PM Keith Dahlby notifications@github.com
wrote:
Exports from system modules are automatically available, but they're
not actually imported until you use a function from them. Since there's
really nothing to "do" with posh-git other than import it, you'll want to
add Import-Module posh-git to $PROFILE before you modify
$GitPromptSettings.Add-PoshGitToProfile can add it for you, but it will add the import at
the end of your profile.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/dahlbyk/posh-git/issues/582#issuecomment-391405343,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AANS8iwWxgcJZ9cJr9nOfSyfMGk3XvrGks5t1YoJgaJpZM4UJdgM
.
Most helpful comment
Adding
Import-Module posh-gitto my User profile _before_ accessing$GitPromptSettingsdid the trick! Sorry for the fuss, I thought themodule loading lifecycle would be more obvious :D
On Wed, May 23, 2018 at 12:10 PM Keith Dahlby notifications@github.com
wrote: