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
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

View file

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