Posh-Git and Posh-Hg Together? Posh-Git and Posh-Hg Together? powershell powershell

Posh-Git and Posh-Hg Together?


Try this one in your profile script:

function isCurrentDirectoryARepository($type) {    if ((Test-Path $type) -eq $TRUE) {        return $TRUE    }    # Test within parent dirs    $checkIn = (Get-Item .).parent    while ($checkIn -ne $NULL) {        $pathToTest = $checkIn.fullname + '/' + $type;        if ((Test-Path $pathToTest) -eq $TRUE) {            return $TRUE        } else {            $checkIn = $checkIn.parent        }    }    return $FALSE}# Posh-Hg and Posh-git prompt. $ProfileRoot\Modules\posh-hg\profile.example.ps1. $ProfileRoot\Modules\posh-git\profile.example.ps1function prompt(){    # Reset color, which can be messed up by Enable-GitColors    $Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor    Write-Host($pwd) -nonewline    if (isCurrentDirectoryARepository(".git")) {        # Git Prompt        $Global:GitStatus = Get-GitStatus        Write-GitStatus $GitStatus    } elseif (isCurrentDirectoryARepository(".hg")) {        # Mercurial Prompt        $Global:HgStatus = Get-HgStatus        Write-HgStatus $HgStatus    }    return "> "}


Please note, that issue is now fixed. Assuming that you have last versions of the Posh-Hg and Posh-Git, your profile should include only.

# Posh-Hg and Posh-git prompt. $ProfileRoot\Modules\posh-hg\profile.example.ps1. $ProfileRoot\Modules\posh-git\profile.example.ps1


FYI - there's a sweet Chocolatey package called Posh-GIT-HG that does exactly what the answer above suggests, but has the added benefit of potentially staying in sync with the latest versions of posh-git and posh-hg.