mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 03:49:40 -08:00
parent
0e25f1613c
commit
aecd8d6bfd
|
@ -32,6 +32,7 @@ type Segment struct {
|
|||
TemplatesLogic template.Logic `json:"templates_logic,omitempty"`
|
||||
Properties properties.Map `json:"properties,omitempty"`
|
||||
Interactive bool `json:"interactive,omitempty"`
|
||||
Alias string `json:"alias,omitempty"`
|
||||
|
||||
writer SegmentWriter
|
||||
Enabled bool `json:"-"`
|
||||
|
@ -384,7 +385,11 @@ func (segment *Segment) SetEnabled(env environment.Environment) {
|
|||
}
|
||||
if segment.writer.Enabled() {
|
||||
segment.Enabled = true
|
||||
env.TemplateCache().AddSegmentData(string(segment.Type), segment.writer)
|
||||
name := segment.Alias
|
||||
if len(name) == 0 {
|
||||
name = string(segment.Type)
|
||||
}
|
||||
env.TemplateCache().AddSegmentData(name, segment.writer)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -358,6 +358,12 @@
|
|||
"title": "Allow the use of interactive prompt escape sequences",
|
||||
"description": "https://ohmyposh.dev/docs/configuration/segment#interactive",
|
||||
"default": false
|
||||
},
|
||||
"alias": {
|
||||
"type": "string",
|
||||
"title": "Give the segment an alias for use in templates",
|
||||
"description": "https://ohmyposh.dev/docs/configuration/segment#alias",
|
||||
"default": ""
|
||||
}
|
||||
},
|
||||
"allOf": [
|
||||
|
|
|
@ -50,6 +50,7 @@ understand how to configure a segment.
|
|||
| `templates_logic` | `string` | <ul><li>`first_match`: return the first non-whitespace string and skip everything else</li><li>`join`:evaluate all templates and join all non-whitespace strings (**default**)</li></ul> |
|
||||
| `properties` | `[]Property` | see [Properties][properties] below |
|
||||
| `interactive` | `boolean` | when is true, the segment text is not escaped to allow the use of interactive prompt escape sequences - defaults to `false` |
|
||||
| `alias` | `string` | for use with [cross segment template properties][cstp] |
|
||||
|
||||
## Style
|
||||
|
||||
|
@ -154,3 +155,4 @@ This means that for user Bill, who has a user account `Bill` on Windows and `bil
|
|||
[regex]: https://www.regular-expressions.info/tutorial.html
|
||||
[templates]: /docs/configuration/templates
|
||||
[color-templates]: /docs/configuration/colors#color-templates
|
||||
[cstp]: templates.mdx#cross-segment-template-properties
|
||||
|
|
|
@ -109,6 +109,41 @@ For this to work, the segment you refer to needs to be in your config. The above
|
|||
your config does not contain a git segment as Oh My Posh only populates the properties when it needs to.
|
||||
:::
|
||||
|
||||
:::tip
|
||||
If you have two identical segments for a different purpose, you can make use of the `alias` property on the segment
|
||||
to distinct between both. For example:
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "command",
|
||||
// highlight-next-line
|
||||
"alias": "Hello",
|
||||
"style": "plain",
|
||||
"foreground": "#ffffff",
|
||||
"properties": {
|
||||
"command": "echo Hello"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "command",
|
||||
// highlight-next-line
|
||||
"alias": "World",
|
||||
"style": "plain",
|
||||
"foreground": "#ffffff",
|
||||
"properties": {
|
||||
"command": "echo World"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"style": "plain",
|
||||
"foreground": "#ffffff",
|
||||
// highlight-next-line
|
||||
"template": "{{ .Segments.Hello.Output }} {{ .Segments.World.Output }}"
|
||||
}
|
||||
```
|
||||
:::
|
||||
|
||||
## Text decoration
|
||||
|
||||
You can make use of the following syntax to decorate text:
|
||||
|
|
Loading…
Reference in a new issue