Windows 终端 + oh-my-posh 不显示 git 状态

Pal*_*lBo 8 posh-git oh-my-zsh windows-terminal

我已经在 Windows 终端中安装了 oh-my-posh 和 posh-git,但是它不会跟踪任何 git 更改,如图所示。不管我做了什么改变,它都只是显示这样,没有状态:

\n

在此输入图像描述

\n

我也尝试过不使用 posh-git,因为我认为 oh-my-posh 默认情况下具有此功能,但结果仍然相同。

\n

这是我的 oh-my-posh 主题:

\n
{\n  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",\n  "blocks": [\n    {\n      "alignment": "left",\n      "segments": [\n        {\n          "background": "#91ddff",\n          "foreground": "#100e23",\n          "powerline_symbol": "\xee\x82\xb0",\n          "properties": {\n            "folder_icon": "\xef\x84\x95",\n            "folder_separator_icon": " \xee\x82\xb1 ",\n            "home_icon": "\xef\x9f\x9b",\n            "style": "agnoster"\n          },\n          "style": "powerline",\n          "type": "path"\n        },\n        {\n          "background": "#95ffa4",\n          "foreground": "#193549",\n          "powerline_symbol": "\xee\x82\xb0",\n          "style": "powerline",\n          "type": "git"\n        },\n        {\n          "background": "#906cff",\n          "foreground": "#100e23",\n          "powerline_symbol": "\xee\x82\xb0",\n          "properties": {\n            "prefix": " \xee\x88\xb5 "\n          },\n          "style": "powerline",\n          "type": "python"\n        },\n        {\n          "background": "#ff8080",\n          "foreground": "#ffffff",\n          "powerline_symbol": "\xee\x82\xb0",\n          "style": "powerline",\n          "type": "exit"\n        }\n      ],\n      "type": "prompt"\n    }\n  ],\n  "final_space": true\n}\n\n
Run Code Online (Sandbox Code Playgroud)\n

Pal*_*lBo 7

在这里找到答案: https: //ohmyposh.dev/docs/git/。显然 git status 默认是禁用的,所以你需要在 git 配置中添加一个属性部分:

{
  "type": "git",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#193549",
  "background": "#ffeb3b",
  "properties": {
    "display_status": true,
    "display_stash_count": true,
    "display_upstream_icon": true
  }
}
Run Code Online (Sandbox Code Playgroud)

也可以使用 posh-git:

{
  "type": "poshgit",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#ffffff",
  "background": "#0077c2"
}
Run Code Online (Sandbox Code Playgroud)