feat: enable posh-git on $GitPromptSettings.EnablePromptStatus

relates to https://github.com/dahlbyk/posh-git/issues/883
This commit is contained in:
Jan De Dobbeleer 2022-03-31 10:45:31 +02:00 committed by Jan De Dobbeleer
parent c7b681a2b5
commit 749eb6cf26
2 changed files with 2 additions and 5 deletions

View file

@ -10,7 +10,6 @@ Display the [posh-git][posh-git] prompt.
:::caution :::caution
This segment only works within Powershell and requires the posh-git module to be installed and imported. This segment only works within Powershell and requires the posh-git module to be installed and imported.
To enable the `posh-git` module, set `$env:POSH_GIT_ENABLED = $true` in your `$PROFILE`.
::: :::
## Sample Configuration ## Sample Configuration

View file

@ -57,11 +57,9 @@ function global:Get-PoshContext {
} }
function global:Initialize-ModuleSupport { function global:Initialize-ModuleSupport {
if ($env:POSH_GIT_ENABLED -eq $true -and (Get-Module -Name "posh-git")) { if ($GitPromptSettings.EnablePromptStatus) {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSProvideCommentHelp', '', Justification = 'Variable used later (not in this scope)')]
$global:GitStatus = Get-GitStatus $global:GitStatus = Get-GitStatus
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSProvideCommentHelp', '', Justification = 'Variable used by posh-git (not in this script)')] $GitPromptSettings.EnablePromptStatus = $false
$GitPromptSettings = $null
$env:POSH_GIT_STATUS = Write-GitStatus -Status $global:GitStatus $env:POSH_GIT_STATUS = Write-GitStatus -Status $global:GitStatus
} }
} }