2021-11-12 10:14:16 -08:00
|
|
|
---
|
2022-04-20 09:43:59 -07:00
|
|
|
id: transient
|
2021-11-12 10:14:16 -08:00
|
|
|
title: Transient prompt
|
|
|
|
sidebar_label: Transient prompt
|
|
|
|
---
|
|
|
|
|
|
|
|
import Tabs from "@theme/Tabs";
|
|
|
|
import TabItem from "@theme/TabItem";
|
|
|
|
|
|
|
|
:::info
|
2022-03-23 02:32:54 -07:00
|
|
|
This feature only works in `fish`, `zsh`, `powershell` and `cmd` for the time being.
|
2021-11-12 10:14:16 -08:00
|
|
|
:::
|
|
|
|
|
|
|
|
Transient prompt, when enabled, replaces the prompt with a simpler one to allow more screen real estate.
|
|
|
|
You can use go [text/template][go-text-template] templates extended with [sprig][sprig] to enrich the text.
|
2022-08-04 22:16:16 -07:00
|
|
|
All [template][templates] functionality is available, even reusing [cross segment template properties][cstp] from
|
|
|
|
the previous primary prompt run.
|
2021-11-12 10:14:16 -08:00
|
|
|
|
|
|
|
Typically, your prompt will simply leave the prompt on the screen when you execute a command (or press enter) like so:
|
|
|
|
|
|
|
|
![Before Transient](/img/transient-before.gif)
|
|
|
|
|
|
|
|
By enabling Transient Prompt, you can replace the prompt with some other content for a cleaner console as shown here:
|
|
|
|
|
|
|
|
![After Transient](/img/transient-after.gif)
|
|
|
|
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
You need to extend or create a custom theme with your transient prompt. For example:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
|
|
|
|
"blocks": {
|
|
|
|
...
|
2022-02-20 04:56:28 -08:00
|
|
|
},
|
2021-11-12 10:14:16 -08:00
|
|
|
"transient_prompt": {
|
|
|
|
"background": "transparent",
|
|
|
|
"foreground": "#ffffff",
|
|
|
|
"template": "{{ .Shell }}> "
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
The configuration has the following properties:
|
|
|
|
|
|
|
|
- foreground: `string` [color][colors]
|
2022-03-24 04:53:20 -07:00
|
|
|
- foreground_templates: foreground [color templates][color-templates]
|
|
|
|
- background: `string` [color][colors]
|
|
|
|
- background_templates: background [color templates][color-templates]
|
2022-08-04 22:16:16 -07:00
|
|
|
- template: `string` - a fully featured [template][templates] - defaults to `{{ .Shell }}> `
|
2021-11-12 10:14:16 -08:00
|
|
|
|
|
|
|
## Enable the feature
|
|
|
|
|
2022-08-04 22:16:16 -07:00
|
|
|
Oh My posh handles enabling the feature automatically for all shells except `cmd` when the config contains a
|
|
|
|
transient prompt configuration. For `cmd`, you can run the command below once to enable the feature permanently:
|
2021-11-18 04:29:56 -08:00
|
|
|
|
|
|
|
```shell
|
|
|
|
clink set prompt.transient always
|
|
|
|
```
|
|
|
|
|
2022-04-20 09:43:59 -07:00
|
|
|
[colors]: /docs/configuration/colors
|
2021-11-12 10:14:16 -08:00
|
|
|
[go-text-template]: https://golang.org/pkg/text/template/
|
2022-04-20 09:43:59 -07:00
|
|
|
[console-title]: /docs/configuration/title#console-title-template
|
2021-11-12 10:14:16 -08:00
|
|
|
[sprig]: https://masterminds.github.io/sprig/
|
2021-11-18 04:29:56 -08:00
|
|
|
[clink]: https://chrisant996.github.io/clink/
|
2022-04-20 09:43:59 -07:00
|
|
|
[templates]: /docs/configuration/templates
|
|
|
|
[color-templates]: /docs/configuration/colors#color-templates
|
2022-08-04 22:16:16 -07:00
|
|
|
[cstp]: /docs/configuration/templates#cross-segment-template-properties
|