Add segment in oh-my-posh if folder name contains certain letters

580 Views Asked by At

I want to dynamically add a segment based on the name of the current directory, here e.g., the abc.

oh-my-posh example

If the directory name is abc, then I want to add a segment showing an icon, e.g., a house, between the git information and the blue success indicator.

How can this be achieved?

1

There are 1 best solutions below

3
On BEST ANSWER

You can make use of the text segment and the following template:

{{ if contains .Folder \"abc\" }}icon{{ end }}

{
  "type": "text",
  "style": "plain",
  "foreground": "#E06C75",
  "template": " {{ if contains .Folder \"abc\" }}icon{{ end }} "
}