首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Posh-Git和Posh-Hg在一起?

Posh-Git和Posh-Hg在一起?
EN

Stack Overflow用户
提问于 2010-12-21 22:11:21
回答 3查看 1.8K关注 0票数 12

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

http://poshhg.codeplex.com/

http://github.com/dahlbyk/posh-git

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2011-01-31 06:16:47

在您的配置文件脚本中尝试以下代码:

代码语言:javascript
复制
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 "> "
}
票数 19
EN

Stack Overflow用户

发布于 2012-06-16 00:22:34

请注意,这个问题现在已经解决了。假设您有Posh-Hg和Posh-Git的最新版本,那么您的配置文件应该只包含。

代码语言:javascript
复制
# Posh-Hg and Posh-git prompt
. $ProfileRoot\Modules\posh-hg\profile.example.ps1
. $ProfileRoot\Modules\posh-git\profile.example.ps1
票数 11
EN

Stack Overflow用户

发布于 2013-02-22 05:18:34

仅供参考-有一个名为Posh-GIT-HG的甜美巧克力包,它完全按照上面的answer建议的那样做,但有一个额外的好处,可能会与最新版本的posh-git和posh-hg保持同步。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4500134

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档