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
|
|
|
|
---
|
|
|
|
|
|
|
|
Let's take a closer look at what defines a block.
|
|
|
|
|
2024-06-21 02:07:13 -07:00
|
|
|
import Config from "@site/src/components/Config.js";
|
|
|
|
|
|
|
|
<Config
|
|
|
|
data={{
|
|
|
|
blocks: [
|
|
|
|
{
|
|
|
|
type: "prompt",
|
|
|
|
alignment: "left",
|
|
|
|
segments: [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}}
|
|
|
|
/>
|
2022-06-03 13:35:11 -07:00
|
|
|
|
2024-11-03 02:10:43 -08:00
|
|
|
## Settings
|
2022-09-16 07:32:48 -07:00
|
|
|
|
2024-06-21 02:07:13 -07:00
|
|
|
| Name | Type |
|
|
|
|
| ------------------ | --------- |
|
|
|
|
| `type` | `string` |
|
|
|
|
| `newline` | `boolean` |
|
|
|
|
| `alignment` | `string` |
|
|
|
|
| `filler` | `string` |
|
|
|
|
| `overflow` | `string` |
|
|
|
|
| `leading_diamond` | `string` |
|
|
|
|
| `trailing_diamond` | `string` |
|
|
|
|
| `segments` | `array` |
|
2021-11-15 10:20:27 -08:00
|
|
|
|
|
|
|
### 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.
|
2024-07-21 06:00:33 -07:00
|
|
|
Supported on zsh, PowerShell, cmd, nu and fish.
|
2024-07-20 14:06:17 -07:00
|
|
|
|
2021-11-15 10:20:27 -08:00
|
|
|
### Newline
|
|
|
|
|
2024-07-13 12:09:47 -07:00
|
|
|
Start the block on a new line - defaults to `false`. For `pwsh` and `cmd` this will not print a newline
|
2023-02-02 05:02:46 -08:00
|
|
|
that's defined on the first block when the prompt is on the first line (when using clear), or when the shell session
|
2024-07-13 12:09:47 -07:00
|
|
|
starts (1st prompt). To enable the same behavior for `bash` and `zsh`, set `enable_cursor_positioning` to `true`.
|
|
|
|
This can have the side effect of swallowing commands you type while the prompt loads, or while the current
|
|
|
|
command is still ongoing. This is a limitation of the shell and not Oh My Posh.
|
|
|
|
|
2021-11-15 10:20:27 -08:00
|
|
|
### Alignment
|
|
|
|
|
2022-09-16 07:32:48 -07:00
|
|
|
- `left`
|
|
|
|
- `right`
|
|
|
|
|
2021-11-15 10:20:27 -08:00
|
|
|
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
|
|
|
|
2024-11-02 13:46:16 -07:00
|
|
|
<Config
|
|
|
|
data={{
|
|
|
|
block: {
|
|
|
|
alignment: "right",
|
|
|
|
filler: ".",
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
/>
|
2021-11-15 10:20:27 -08:00
|
|
|
|
2022-06-27 10:39:31 -07:00
|
|
|
### Overflow
|
|
|
|
|
2022-09-16 07:32:48 -07:00
|
|
|
- `break`
|
|
|
|
- `hide`
|
|
|
|
|
2022-06-27 10:39:31 -07:00
|
|
|
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.
|
|
|
|
|
2024-06-21 02:07:13 -07:00
|
|
|
### Leading Diamond
|
|
|
|
|
|
|
|
The character to use as a leading diamond for the first segment in case you always want to start the block
|
|
|
|
with the same leading diamond, regardless of which segment is enabled or not.
|
|
|
|
|
|
|
|
### Trailing Diamond
|
|
|
|
|
|
|
|
The character to use as a trailing diamond for the last segment in case you always want to end the block
|
|
|
|
with the same trailing diamond, regardless of which segment is enabled or not.
|
|
|
|
|
2021-11-15 10:20:27 -08:00
|
|
|
### Segments
|
|
|
|
|
2022-09-16 07:32:48 -07:00
|
|
|
Array of one or more [segments][segment].
|
2022-02-12 09:40:02 -08:00
|
|
|
|
2022-04-20 09:43:59 -07:00
|
|
|
[color-overrides]: /docs/configuration/colors#color-overrides
|
2022-09-16 07:32:48 -07:00
|
|
|
[segment]: segment.mdx
|