From 749eb6cf263fd960644b9d099d973c7c94af4958 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Thu, 31 Mar 2022 10:45:31 +0200 Subject: [PATCH] feat: enable posh-git on $GitPromptSettings.EnablePromptStatus relates to https://github.com/dahlbyk/posh-git/issues/883 --- docs/docs/segment-posh-git.mdx | 1 - src/shell/scripts/omp.ps1 | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/docs/segment-posh-git.mdx b/docs/docs/segment-posh-git.mdx index 0664129a..8099feae 100644 --- a/docs/docs/segment-posh-git.mdx +++ b/docs/docs/segment-posh-git.mdx @@ -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 diff --git a/src/shell/scripts/omp.ps1 b/src/shell/scripts/omp.ps1 index a9c4125a..53a1a6b0 100644 --- a/src/shell/scripts/omp.ps1 +++ b/src/shell/scripts/omp.ps1 @@ -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 } }