0

I am very new to this, but I am trying to make my own oh-my-posh theme (basically by comparing, copying and trying sections from other themes and combining them). I am using pwsh and I am using JetBrainsMono Nerd Font.

My theme works fine so far, but for the git functionality I am seeing this question mark when I have unstaged files. The git code section in the JSON looks like this:

    {
      "background": "#00C853",
      "background_templates": [
          "{{ if or (.Working.Changed) (.Staging.Changed) }}#FFEB3B{{ end }}",
          "{{ if and (gt .Ahead 0) (gt .Behind 0) }}#FFCC80{{ end }}",
          "{{ if gt .Ahead 0 }}#B388FF{{ end }}",
          "{{ if gt .Behind 0 }}#B388FF{{ end }}"
      ],
      "foreground": "#000000",
      "powerline_symbol": "\ue0b0",
      "properties": {
          "fetch_stash_count": true,
          "fetch_status": true
      },
      "style": "powerline",
      "template": " {{ .HEAD }}{{ if .Staging.Changed }}<#FF6F00> \uf046 {{ .Staging.String }}</>{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if gt .StashCount 0 }} \ueb4b {{ .StashCount }}{{ end }} ",
      "type": "git"
    }

You can see the output here:

enter image description here

I have tried replacing all the \u... symbols, but they apparently are not the problem. Can someone lend me a hand here?

MRE: JSON of the theme:

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "alignment": "left",
      "segments": [
        {
          "background": "#07585c",
          "foreground": "#ffffff",
          "leading_diamond": "\ue0b6",
          "style": "diamond",
          "template": " {{ .UserName }}@{{ .HostName }} ",
          "trailing_diamond": "\ue0b0",
          "type": "session"
        },
        {
          "background": "#444444",
          "foreground": "#E4E4E4",
          "properties": {
            "style": "full"
          },
          "style": "diamond",
          "template": " {{ .Path }} ",
          "type": "path"
        },
        {
          "background": "#00C853",
          "background_templates": [
              "{{ if or (.Working.Changed) (.Staging.Changed) }}#FFEB3B{{ end }}",
              "{{ if and (gt .Ahead 0) (gt .Behind 0) }}#FFCC80{{ end }}",
              "{{ if gt .Ahead 0 }}#B388FF{{ end }}",
              "{{ if gt .Behind 0 }}#B388FF{{ end }}"
          ],
          "foreground": "#000000",
          "powerline_symbol": "\ue0b0",
          "properties": {
              "fetch_stash_count": true,
              "fetch_status": true
          },
          "style": "powerline",
          "template": " {{ .HEAD }}{{ if .Staging.Changed }}<#FF6F00> \uf046 {{ .Staging.String }}</>{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if gt .StashCount 0 }} \ueb4b {{ .StashCount }}{{ end }} ",
          "type": "git"
        },
        {
          "background": "#575656",
          "foreground": "#d6deeb",
          "properties": {
            "style": "roundrock",
            "threshold": 0
          },
          "style": "diamond",
          "template": " {{ .FormattedMs }}",
          "trailing_diamond": "\ue0b4",
          "type": "executiontime"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "right",
      "overflow": "break",
      "segments": [
        {
          "background": "#d6deeb",
          "foreground": "#011627",
          "leading_diamond": "\ue0b6",
          "style": "diamond",
          "template": "\uf489  {{ .Name }} ",
          "type": "shell"
        },
        {
          "background": "#234d70",
          "foreground": "#d6deeb",
          "properties": {
            "time_format": "15:04:05"
          },
          "style": "diamond",
          "template": " \ue641 {{ .CurrentDate | date .Format }}",
          "trailing_diamond": "\ue0b4",
          "type": "time"
        },
        {
          "background": "#306998",
          "foreground": "#FFE873",
          "leading_diamond": "\ue0b2",
          "style": "diamond",
          "template": "\ue235  {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }}",
          "trailing_diamond": "<transparent,#306998>\ue0b2</>",
          "type": "python"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "foreground": "#22da6e",
          "foreground_templates": ["{{ if gt .Code 0 }}#ef5350{{ end }}"],
          "properties": {
            "always_enabled": true
          },
          "style": "plain",
          "template": "\ue285\ue285",
          "type": "status"
        }
      ],
      "type": "prompt"
    }    
  ],
  "final_space": true,
  "version": 2
}

Open pwsh, make a folder, run git init, create a file (e.g. New-Item bar.txt), see the Git Powerline block change from green to yellow and this icon appear (there will be a "1" instead of a "2" if you only created one file in your git directory). To have the same output, install JetBrainsMono Nerd Font, but CascaydiaCove Nerd Font gives the same problem. Also you should have the lines

Import-Module posh-git
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/theme-name.omp.json" | Invoke-Expression

in your Microsoft.PowerShell_profile.ps1.

Felix
  • 21
  • 7

0 Answers0