我正在使用posh-git将git信息添加到我的PowerShell提示符中。我想让我的提示符包括远程仓库名称,就像这些示例那样,但是找不到方法来实现。
下面是我的自定义提示符配置文件:
下面是我的自定义提示符配置文件:
function prompt {
$origLastExitCode = $LASTEXITCODE
$curPath = $ExecutionContext.SessionState.Path.CurrentLocation.Path
if ($curPath.ToLower().StartsWith($Home.ToLower())) {
$curPath = "~" + $curPath.SubString($Home.Length)
}
Write-Host "$env:UserName" -NoNewline -ForegroundColor Cyan
Write-Host "@" -NoNewline -ForegroundColor Yellow
Write-Host "$(hostname)" -NoNewline
Write-VcsStatus
Write-Host "`n$curPath" -NoNewline
$LASTEXITCODE = $origLastExitCode
" $('>' * ($nestedPromptLevel + 1)) "
}
Import-Module posh-git
$global:GitPromptSettings.BeforeText = " ("
$global:GitPromptSettings.AfterText = ")"
$global:GitPromptSettings.EnableWindowTitle = "posh-git ~"
$global:GitPromptSettings.EnableStashStatus = $true
$global:GitPromptSettings.BeforeStashText = " {"
$global:GitPromptSettings.AfterStashText = "}"
$global:GitPromptSettings.BeforeStashForegroundColor = "Yellow"
$global:GitPromptSettings.AfterStashForegroundColor = "Yellow"
$global:GitPromptSettings.BranchUntrackedSymbol = "::"
$global:GitPromptSettings.BranchGoneStatusSymbol = "~~"
$global:GitPromptSettings.BranchIdenticalStatusToSymbol = "=="
$global:GitPromptSettings.BranchAheadStatusSymbol = "<<"
$global:GitPromptSettings.BranchBehindStatusSymbol = ">>"
$global:GitPromptSettings.BranchBehindAndAheadStatusSymbol = "><"
这是结果:
spike@Jacob-Laptop (master == +0 ~1 -0 !)
~\Documents\Projects\GUI Utilities\batch-media-file-converter >
This is what I want:
spike@Jacob-Laptop [spikespaz/batch-media-file-converter] (master == +0 ~1 -0 !)
~\Documents\Projects\GUI Utilities\batch-media-file-converter >