mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-02 05:41:10 -08:00
Some checks failed
Code QL / code-ql (push) Waiting to run
Release / changelog (push) Waiting to run
Release / artifacts (push) Blocked by required conditions
Release / msi (arm64) (push) Blocked by required conditions
Release / msi (x64) (push) Blocked by required conditions
Release / msi (x86) (push) Blocked by required conditions
Release / cdn (arm64) (push) Blocked by required conditions
Release / cdn (x64) (push) Blocked by required conditions
Release / cdn (x86) (push) Blocked by required conditions
Release / release (push) Blocked by required conditions
Azure Static Web Apps CI/CD / Build and Deploy (push) Has been cancelled
This change allows the user to specify a template for filler so that different behavior can be configured when the block is handling an overflow. An example configuration might be: ```yaml - type: prompt alignment: right filler: "{{ if .Overflow }} {{ else }}<#3d59a1,transparent>━</>{{ end }}" overflow: break ``` This would draw filler text ("-") when there is no overflow and empty space when there is an overflow.
119 lines
3.5 KiB
Plaintext
119 lines
3.5 KiB
Plaintext
---
|
|
id: block
|
|
title: Block
|
|
sidebar_label: Block
|
|
---
|
|
|
|
Let's take a closer look at what defines a block.
|
|
|
|
import Config from "@site/src/components/Config.js";
|
|
|
|
<Config
|
|
data={{
|
|
blocks: [
|
|
{
|
|
type: "prompt",
|
|
alignment: "left",
|
|
segments: [],
|
|
},
|
|
],
|
|
}}
|
|
/>
|
|
|
|
## Settings
|
|
|
|
| Name | Type |
|
|
| ------------------ | --------- |
|
|
| `type` | `string` |
|
|
| `newline` | `boolean` |
|
|
| `alignment` | `string` |
|
|
| `filler` | `string` |
|
|
| `overflow` | `string` |
|
|
| `leading_diamond` | `string` |
|
|
| `trailing_diamond` | `string` |
|
|
| `segments` | `array` |
|
|
|
|
### Type
|
|
|
|
Tells the engine what to do with the block. There are two options:
|
|
|
|
- `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.
|
|
Supported on zsh, PowerShell, cmd, nu and fish.
|
|
|
|
### Newline
|
|
|
|
Start the block on a new line - defaults to `false`. For `pwsh` and `cmd` this will not print a newline
|
|
that's defined on the first block when the prompt is on the first line (when using clear), or when the shell session
|
|
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.
|
|
|
|
### Alignment
|
|
|
|
- `left`
|
|
- `right`
|
|
|
|
Tell the engine if the block should be left or right-aligned.
|
|
|
|
### Filler
|
|
|
|
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].
|
|
|
|
<Config
|
|
data={{
|
|
block: {
|
|
alignment: "right",
|
|
filler: ".",
|
|
},
|
|
}}
|
|
/>
|
|
|
|
Filler allows you to specify a template to tweak the text used as filler. This template behaves the same as
|
|
Segment templates, however, fewer properties are available.
|
|
|
|
| Name | Type | Description |
|
|
| ----------- | ------ | --------------------------------------------------------------------- |
|
|
| `.Overflow` | `text` | if no overflow was needed, this is empty. Otherwise `hide` or `break` |
|
|
| `.Padding` | `int` | the computed length of the padding between left and right blocks |
|
|
|
|
This can be very useful if you wish to use a filler text when there is no overflow and use
|
|
empty space when the right block is hidden or drawn on a newline due to overflow.
|
|
|
|
<Config
|
|
data={{
|
|
block: {
|
|
alignment: "right",
|
|
overflow: "hide",
|
|
filler: "{{ if .Overflow }} {{ else }}-{{ end }}",
|
|
},
|
|
}}
|
|
/>
|
|
|
|
### Overflow
|
|
|
|
- `break`
|
|
- `hide`
|
|
|
|
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.
|
|
|
|
### 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.
|
|
|
|
### Segments
|
|
|
|
Array of one or more [segments][segment].
|
|
|
|
[color-overrides]: /docs/configuration/colors#color-overrides
|
|
[segment]: segment.mdx
|