git status prompt is not shown in PowerShell

134 Views Asked by At
function prompt {
    $time = Get-Date -Format "HH:mm"
    $location = (Get-Location -PSProvider FileSystem).Path

    $promptText = "["
    $promptText += "$([char]27)[96m$time$([char]27)[0m "
    $promptText += "$([char]27)[32momkrbhagat$([char]27)[0m "
    $promptText += "$([char]27)[35m$location$([char]27)[0m"

    Write-Host $promptText -NoNewline
    return " ~ "
}

This is my own custom prompt for PowerShell. I have posh-git installed and imported module in my $PROFILE too. Git commands tab completion also works well, but when I initialize my git repository didn't see Git status prompt. I think my own custom prompt affects showing Git status prompt. So, how can I integrate my own prompt and Git status prompt.

I expect the following output : [HH:mm] omkrbhagat C:\Users\onkar (master) ~

For this I append the following line : if (Test-Path variable:GitPromptSettings) { Write-VcsStatus }

But still didn't work. Apart from that when I initialize the git repository only then and then the git status prompt should be shown.

1

There are 1 best solutions below

0
On

Check this file "about_posh-git.help.txt".

If you would like fine grained control over how the Git status summary information is displayed in your prompt function, you can get the raw status summary information via the Get-GitStatus command. Then you can display the information in your prompt however you would like.