Windows Terminal(哦,我的posh)在我尝试过的任何事情之后都不会显示git状态

发布于 2025-01-22 17:25:05 字数 2195 浏览 3 评论 0 原文

Description

  1. 我导入POSH-GIT,但不要使用其及时的样式。和我的Windows Terminal $ profile,例如:

    •  进口模块posh-git
      进口模块OH-MY POSH
      Set -Posh Prompt-主题默认值
      #$ env:posh_git_enabled = $ true
       
  2. 我已经阅读了类似的问题[ Windows terminal + OH - 我的posh不显示git状态并使主题文件更改,但也行不通。

    • 主题文件的“ git”段如:

        {
                “ type”:“ git”,
                “背景”:“ P:绿色”,
                “ background_templates”:[
                  “ {{if或(.working.changed)(.staging.changed)}}} p:yellow {{end}}”,
                  “ {{{if和(gt .ahead 0)(gt .behind 0)}}} p:red {{end}}”,
                  “ {{ifgt .ahead 0}}#49416d {{end}}”,
                  “ {{ifgt .behind 0}}#7a306c {{end}}”
                ],,
                “前景”:“ P:Black”,
                “ foreground_templates”:[
                  “ {{if或(.working.changed)(.staging.changed)}}} p:black {{end}}”,
                  “ {{{if和(gt .ahead 0)(gt .behind 0)}}} p:white {{end}}”,
                  “ {{ifgt .ahead 0}} p:white {{end}}”
                ],,
                “ powerline_symbol”:“ \ ue0b0”,
                “特性”: {
                  “ display_status”:是的,
                  “ display_stash_count”:是的,
                  “ display_upstream_icon”:是的,
                  “ branch_max_length”:25,
                  “ fetch_status”:是的,
                  “ fetch_upstream_icon”:是的,
                  “ github_icon”:“ \ uf7a3”
                },,
                “样式”:“ Powerline”,
                “ template”:“ {{if .upstreamurl}}} {{url .upstreamicon .upstreamurl}}}}}} {{end}} {.head}} {.head}} {.branchstatus}}}} {.working.string}}} {{end}} {{if .staging.changed}}} \ uf046 {{.staging.String}}}} {eend}} {end end}}}}}
          },,
       

      所有显示属性(“ display_status” ...)都是True。

图像:

它不显示git状态!!为什么??

“

只想知道oh-my-posh是否已弃用了git状态显示??

我已经阅读了 oh-my-posh博客页面,Git状态显示没有更改

description

  1. 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
      
  2. 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.

image:

it doesn't display git status!! why??

Prompt with status missing

Question

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半边脸i 2025-01-29 17:25:05
  1. oh-my-posh 已弃用了他们的powershell模块,
    因此,作为第一步,运行文档中概述的迁移步骤,并替换 import-module oh-my-posh 以及 set poshprompt- theme default with for,for,for例如,

      oh-my-posh init pwsh -config〜/.custom.omp.json |调用表达
     

  2. uncomment

     #$ env:posh_git_enabled = $ true
     

    so posh-git 已启用。 posh-git 提示被默认禁用::

    PowerShell提供了对 posh-git 自动完成的模块的支持,但默认情况下是禁用的。要启用此功能,请设置 $ env:posh_git_enabled = $ true 在您的 $ profile

  3. posh-git readme ,它说:

    POSH-GIT如果提示功能检测到您有自己的自定义提示功能。

    很好,所以这就是我们所追求的:在 oh-my-posh 上使用 posh-git 提示。那么我们如何将后者纳入前者?

  4. 在您的 oh-my-posh.omp.json 配置文件,添加 处于您选择的位置:

      {
      “ type”:“ poshgit”,
      “样式”:“ Powerline”,
      “ powerline_symbol”:“ \ ue0b0”,
      “前景”:“ #ffffff”,
      “背景”:“#0077C2”
    }
     

    这里的相关区别在于,这是类型 poshgit ,而不是类型 git> git (后者是 oh-my-posh 据我所知,“内置”)。


这对我™有效,作为第一个近似值。您需要添加自定义 foreground_template 魔术等以进一步自定义,但是这些设置应允许 posh-git 提示至少从中显示至少显示哦,我的posh 一个。

  1. 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
    
  2. 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.

  3. 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?

  4. 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文