Reputation: 71
I import posh-git but don't use its prompt style. and my windows terminal $PROFILE like:
Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme default
#$env:POSH_GIT_ENABLED = $true
I have read the similar question [Windows Terminal + oh-my-posh not showing git status and made the theme file change, but it also doesn't work.
the "git" segment of the theme file like:
{
"type": "git",
"background": "p:green",
"background_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}p:yellow{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:red{{ end }}",
"{{ if gt .Ahead 0 }}#49416D{{ end }}",
"{{ if gt .Behind 0 }}#7A306C{{ end }}"
],
"foreground": "p:black",
"foreground_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}p:black{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:white{{ end }}",
"{{ if gt .Ahead 0 }}p:white{{ end }}"
],
"powerline_symbol": "\ue0b0",
"properties": {
"display_status": true,
"display_stash_count": true,
"display_upstream_icon": true,
"branch_max_length": 25,
"fetch_status": true,
"fetch_upstream_icon": true,
"github_icon": "\uf7a3"
},
"style": "powerline",
"template": " {{ if .UpstreamURL }}{{ url .UpstreamIcon .UpstreamURL }} {{ end }}{{ .HEAD }}{{ .BranchStatus }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }} "
},
all the display properties("display_status" ...) are true.
it doesn't display git status!! why??
I just want to know whether oh-my-posh has deprecated the git status display ???
and I have read the oh-my-posh Blog page, there is no changes on git status display
Upvotes: 7
Views: 4277
Reputation: 229
oh-my-posh
has deprecated their PowerShell module and is asking users to migrate.
So as a first step, run the migration steps outlined in the docs and replace Import-Module oh-my-posh
as well as Set-PoshPrompt -Theme default
with, for example,
oh-my-posh init pwsh --config ~/.custom.omp.json | Invoke-Expression
Uncomment
#$env:POSH_GIT_ENABLED = $true
so posh-git
is enabled. The posh-git
prompt is disabled by default:
PowerShell offers support for the
posh-git
module for autocompletion, but it is disabled by default. To enable this, set$env:POSH_GIT_ENABLED = $true
in your$PROFILE
.
In the posh-git
README, it says:
posh-git will not replace the prompt function if it has detected that you have your own, customized prompt function.
Good, so this is what we're after: using oh-my-posh
over the posh-git
prompt. So how do we get the latter into the former?
In your oh-my-posh.omp.json
configuration file, add a segment at a position of your choice:
{
"type": "poshgit",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#0077c2"
}
The relevant difference here is that this is of type poshgit
, not of type git
anymore (the latter being the oh-my-posh
"builtin" as far as I see).
This works for me™, as a first approximation. You'll need to add custom foreground_template
magic etc. to further customize it, but these settings should allow the posh-git
prompt to at least display from within your oh-my-posh
one.
Upvotes: 4