Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

oh-my-posh

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?

like image 348
user69453 Avatar asked Dec 14 '25 22:12

user69453


1 Answers

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 }} "
}

like image 123
Jan De Dobbeleer Avatar answered Dec 16 '25 22:12

Jan De Dobbeleer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!