oh-my-posh/website/docs/configuration/line-error.mdx

62 lines
2.3 KiB
Plaintext
Raw Normal View History

2022-02-19 07:49:26 -08:00
---
2022-04-20 09:43:59 -07:00
id: line-error
2022-02-19 07:49:26 -08:00
title: Line error
sidebar_label: Line error
---
:::info
This feature only works in `powershell` for the time being.
:::
Line error, when enabled, replaces the last part of the prompt when the text entered is invalid. It leverages
[PSReadLine's][psreadline] `-PromptText` setting by adding two distinct prompts. One for a valid line,
and one for when there's an error. As PSReadLine will rewrite the last part of
your prompt with the value of either based on the line's context, you will need to make sure everything
is compatible with your config as **these values are only set once** on shell start.
There are two config settings you need to tweak:
- `valid_line`: displays when the line is valid (again)
- `error_line`: displays when the line is faulty
2022-02-19 07:49:26 -08:00
You can use go [text/template][go-text-template] templates extended with [sprig][sprig] to enrich the text.
## Configuration
You need to extend or create a custom theme with your prompt overrides. For example:
```json
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
2022-02-19 07:49:26 -08:00
...
],
2022-02-19 07:49:26 -08:00
"valid_line": {
"background": "transparent",
"foreground": "#ffffff",
"template": "<#e0def4,#286983>\uf42e </><#286983,transparent>\ue0b4</> "
},
"error_line": {
"background": "transparent",
"foreground": "#ffffff",
"template": "<#eb6f92,#286983>\ue009 </><#286983,transparent>\ue0b4</> "
}
}
```
## Properties
2022-02-19 07:49:26 -08:00
| Name | Type | Description |
| ------------ | -------- | ---------------------------------------------------------- |
| `background` | `string` | [color][colors] |
| `foreground` | `string` | [color][colors] |
| `template` | `string` | a fully featured [template][templates] - defaults to empty |
2022-02-19 07:49:26 -08:00
2022-07-10 05:43:53 -07:00
[colors]: /docs/configuration/colors
2022-02-19 07:49:26 -08:00
[go-text-template]: https://golang.org/pkg/text/template/
[sprig]: https://masterminds.github.io/sprig/
2022-04-20 09:43:59 -07:00
[console-title]: /docs/configuration/title#console-title-template
2022-02-19 07:49:26 -08:00
[psreadline]: https://github.com/PowerShell/PSReadLine
2022-04-20 09:43:59 -07:00
[templates]: /docs/configuration/templates
[cstp]: /docs/configuration/templates#cross-segment-template-properties