2021-11-12 10:14:16 -08:00
|
|
|
---
|
|
|
|
id: config-transient
|
|
|
|
title: Transient prompt
|
|
|
|
sidebar_label: Transient prompt
|
|
|
|
---
|
|
|
|
|
|
|
|
import Tabs from "@theme/Tabs";
|
|
|
|
import TabItem from "@theme/TabItem";
|
|
|
|
|
|
|
|
:::info
|
2021-11-18 04:29:56 -08:00
|
|
|
This feature only works in `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.
|
|
|
|
Environment variables are available, just like the [`console_title_template`][console-title] functionality.
|
|
|
|
|
|
|
|
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": {
|
|
|
|
...
|
|
|
|
}
|
|
|
|
"transient_prompt": {
|
|
|
|
"background": "transparent",
|
|
|
|
"foreground": "#ffffff",
|
|
|
|
"template": "{{ .Shell }}> "
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
The configuration has the following properties:
|
|
|
|
|
|
|
|
- background: `string` [color][colors]
|
|
|
|
- foreground: `string` [color][colors]
|
|
|
|
- template: `string` - A go [text/template][go-text-template] template extended with [sprig][sprig] utilizing the
|
|
|
|
properties below. Defaults to `{{ .Shell }}> `
|
|
|
|
|
2021-11-13 14:46:06 -08:00
|
|
|
## Template Properties
|
2021-11-12 10:14:16 -08:00
|
|
|
|
|
|
|
- `.Root`: `boolean` - is the current user root/admin or not
|
|
|
|
- `.Path`: `string` - the current working directory
|
|
|
|
- `.Folder`: `string` - the current working folder
|
|
|
|
- `.Shell`: `string` - the current shell name
|
|
|
|
- `.User`: `string` - the current user name
|
|
|
|
- `.Host`: `string` - the host name
|
|
|
|
- `.Env.VarName`: `string` - Any environment variable where `VarName` is the environment variable name
|
|
|
|
|
|
|
|
## Enable the feature
|
|
|
|
|
|
|
|
<Tabs
|
|
|
|
defaultValue="pwsh"
|
|
|
|
groupId="shell"
|
|
|
|
values={[
|
|
|
|
{ label: 'powershell', value: 'pwsh', },
|
2021-11-18 04:29:56 -08:00
|
|
|
{ label: 'cmd', value: 'cmd', },
|
2021-11-12 10:14:16 -08:00
|
|
|
{ label: 'zsh', value: 'zsh', },
|
|
|
|
]
|
|
|
|
}>
|
|
|
|
<TabItem value="pwsh">
|
|
|
|
|
|
|
|
|
|
|
|
Import/invoke Oh My Posh in your `$PROFILE` and add the following line below:
|
|
|
|
|
2021-11-13 04:30:41 -08:00
|
|
|
```powershell
|
2021-11-12 10:14:16 -08:00
|
|
|
Enable-PoshTransientPrompt
|
|
|
|
```
|
|
|
|
|
|
|
|
Restart your shell or reload your `$PROFILE` using `. $PROFILE` for the changes to take effect.
|
|
|
|
|
2021-11-18 04:29:56 -08:00
|
|
|
</TabItem>
|
|
|
|
<TabItem value="cmd">
|
|
|
|
|
|
|
|
Set the transient prompt in [clink][clink] to `always` in the `oh-my-posh.lua` script to enable the feature:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
clink set prompt.transient always
|
|
|
|
```
|
|
|
|
|
|
|
|
Restart your shell for the changes to take effect.
|
|
|
|
|
2021-11-12 10:14:16 -08:00
|
|
|
</TabItem>
|
|
|
|
<TabItem value="zsh">
|
|
|
|
|
|
|
|
Invoke Oh My Posh in `.zshrc` and add the following line below:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
enable_poshtransientprompt
|
|
|
|
```
|
|
|
|
|
|
|
|
Restart your shell or reload `.zshrc` using `source ~/.zshrc` for the changes to take effect.
|
|
|
|
|
|
|
|
</TabItem>
|
|
|
|
</Tabs>
|
|
|
|
|
|
|
|
[colors]: /docs/config-colors
|
|
|
|
[go-text-template]: https://golang.org/pkg/text/template/
|
|
|
|
[console-title]: /docs/config-title#console-title-template
|
|
|
|
[sprig]: https://masterminds.github.io/sprig/
|
2021-11-18 04:29:56 -08:00
|
|
|
[clink]: https://chrisant996.github.io/clink/
|