2010-12-21 18 views

Respuesta

19

prueba este perfil en el 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.ps1 

function 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 "> " 
} 
+0

Voy a probar esto esta noche y ver si funciona, gracias por intentar incluso responder esto. –

+1

FUNCIONÓ !!!! Si pudiera darle más de una marca de verificación, lo haría totalmente. –

+0

gracias por esto, funcionó muy bien para mí también. –

11

Tenga en cuenta, que el problema ha sido arreglado. Suponiendo que tiene las últimas versiones de Posh-Hg y Posh-Git, su perfil debe incluir solo.

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

FYI - hay un paquete de Chocolatey dulce llamado Posh-GIT-HG que hace exactamente lo que el answer anterior sugiere, pero tiene la ventaja añadida de potencialmente permanecer en sintonía con las últimas versiones de pijo-GIT y elegante-hg.