2021-11-15 10:20:27 -08:00
|
|
|
---
|
2022-04-20 09:43:59 -07:00
|
|
|
id: block
|
2021-11-15 10:20:27 -08:00
|
|
|
title: Block
|
|
|
|
sidebar_label: Block
|
|
|
|
---
|
|
|
|
|
2022-06-03 13:35:11 -07:00
|
|
|
import Tabs from "@theme/Tabs";
|
|
|
|
import TabItem from "@theme/TabItem"
|
|
|
|
|
2021-11-15 10:20:27 -08:00
|
|
|
Let's take a closer look at what defines a block.
|
|
|
|
|
2022-06-03 13:35:11 -07:00
|
|
|
<Tabs
|
|
|
|
defaultValue="json"
|
|
|
|
groupId="sample"
|
|
|
|
values={[
|
|
|
|
{ label: 'json', value: 'json', },
|
|
|
|
{ label: 'yaml', value: 'yaml', },
|
|
|
|
{ label: 'toml', value: 'toml', },
|
|
|
|
]
|
|
|
|
}>
|
|
|
|
<TabItem value="json">
|
|
|
|
|
2021-11-15 10:20:27 -08:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
|
|
|
|
...
|
|
|
|
"blocks": [
|
|
|
|
{
|
|
|
|
"type": "prompt",
|
|
|
|
"alignment": "left",
|
|
|
|
"segments": [
|
|
|
|
...
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2022-06-03 13:35:11 -07:00
|
|
|
</TabItem>
|
|
|
|
<TabItem value="yaml">
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
# yaml-language-server: $schema=https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
|
|
|
|
...
|
|
|
|
blocks:
|
|
|
|
- type: prompt
|
|
|
|
alignment: left
|
|
|
|
segments: [
|
|
|
|
...
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
</TabItem>
|
|
|
|
<TabItem value="toml">
|
|
|
|
|
|
|
|
```toml
|
|
|
|
"$schema" = "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json"
|
|
|
|
|
|
|
|
[[blocks]]
|
|
|
|
type = "prompt"
|
|
|
|
alignment = "left"
|
|
|
|
segments = [
|
|
|
|
...
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
</TabItem>
|
|
|
|
</Tabs>
|
|
|
|
|
2021-11-15 10:20:27 -08:00
|
|
|
- type: `prompt` | `rprompt`
|
|
|
|
- newline: `boolean`
|
|
|
|
- alignment: `left` | `right`
|
2022-02-04 08:22:40 -08:00
|
|
|
- filler: `string`
|
2022-06-27 10:39:31 -07:00
|
|
|
- overflow: `break` | `hide`
|
2021-11-15 10:20:27 -08:00
|
|
|
- segments: `array` of one or more `segments`
|
|
|
|
|
|
|
|
### Type
|
|
|
|
|
2022-02-03 14:13:41 -08:00
|
|
|
Tells the engine what to do with the block. There are two options:
|
2021-11-15 10:20:27 -08:00
|
|
|
|
|
|
|
- `prompt` renders one or more segments
|
|
|
|
- `rprompt` renders one or more segments aligned to the right of the cursor. Only one `rprompt` block is permitted.
|
2021-12-01 10:11:38 -08:00
|
|
|
Supported on zsh, bash, PowerShell, cmd and fish.
|
2021-11-15 10:20:27 -08:00
|
|
|
|
|
|
|
### Newline
|
|
|
|
|
2021-11-20 02:14:26 -08:00
|
|
|
Start the block on a new line - defaults to `false`.
|
2021-11-15 10:20:27 -08:00
|
|
|
|
|
|
|
### Alignment
|
|
|
|
|
|
|
|
Tell the engine if the block should be left or right-aligned.
|
|
|
|
|
2022-02-04 08:22:40 -08:00
|
|
|
### Filler
|
2021-11-15 10:20:27 -08:00
|
|
|
|
2022-02-12 09:40:02 -08:00
|
|
|
When you want to join a right and left aligned block with a repeated set of characters, add the character(s)
|
|
|
|
to be repeated to this property. Add this property to the _right_ aligned block. This supports the use of
|
|
|
|
[color overrides][color-overrides].
|
2021-11-15 10:20:27 -08:00
|
|
|
|
2022-02-04 08:22:40 -08:00
|
|
|
```json
|
2022-02-06 02:01:46 -08:00
|
|
|
"alignment": "right",
|
2022-02-04 08:22:40 -08:00
|
|
|
"filler": "."
|
|
|
|
```
|
2021-11-15 10:20:27 -08:00
|
|
|
|
2022-06-27 10:39:31 -07:00
|
|
|
### Overflow
|
|
|
|
|
|
|
|
When the right aligned block is so long it will overflow the left aligned block, the engine will either
|
|
|
|
break the block or hide it based on the setting. By default it is printed as is on the same line.
|
|
|
|
|
2021-11-15 10:20:27 -08:00
|
|
|
### Segments
|
|
|
|
|
|
|
|
Array of one or more segments.
|
2022-02-12 09:40:02 -08:00
|
|
|
|
2022-04-20 09:43:59 -07:00
|
|
|
[color-overrides]: /docs/configuration/colors#color-overrides
|