docs: how to hide segments

This commit is contained in:
Claudio Spizzi 2022-03-09 15:16:27 +01:00 committed by Jan De Dobbeleer
parent 0e1c0fb7b2
commit 403a0b2fb5

View file

@ -41,6 +41,28 @@ You can make use of the following syntax to decorate text:
This can be used in templates and icons/text inside your config.
## Hidings segments
To hide a whole segment including the leading and trailing symbol based on a template, the template must render into
an empty string. This can be achieved with conditional statements (`if`). The example below will render a diamond
segment, only if the environment variable `POSH_ENV` is not empty.
Only spaces are excluded, meaning you can still add line breaks and tabs if that is something you're after.
```json
{
"type": "text",
"style": "diamond",
"leading_diamond": " \ue0b6",
"trailing_diamond": "\ue0b4",
"foreground": "#ffffff",
"background": "#d53c14",
"properties": {
"template": "{{ if .Env.POSH_ENV }} \uf8c5 {{ .Env.POSH_ENV }} {{ end }}"
}
}
```
[terminal-list-hyperlinks]: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
[path-segment]: /docs/path
[git-segment]: /docs/git