你好,我是一个巨大的粉丝Git和汞,并必须在许多项目中使用它们。我目前使用的是Posh-Hg,这是一个powershell插件,它将当前分支和未完成的提交放在powershell中。除了Git之外,Posh-Git的运行方式与此类似。有没有人成功地让这两个powershell脚本很好地结合在一起?
http://poshhg.codeplex.com/
http://github.com/dahlbyk/posh-git

发布于 2011-01-31 06:16:47
在您的配置文件脚本中尝试以下代码:
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 "> "
}发布于 2012-06-16 00:22:34
请注意,这个问题现在已经解决了。假设您有Posh-Hg和Posh-Git的最新版本,那么您的配置文件应该只包含。
# Posh-Hg and Posh-git prompt
. $ProfileRoot\Modules\posh-hg\profile.example.ps1
. $ProfileRoot\Modules\posh-git\profile.example.ps1发布于 2013-02-22 05:18:34
仅供参考-有一个名为Posh-GIT-HG的甜美巧克力包,它完全按照上面的answer建议的那样做,但有一个额外的好处,可能会与最新版本的posh-git和posh-hg保持同步。
https://stackoverflow.com/questions/4500134
复制相似问题