mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-08 01:37:26 -08:00
152 lines
4.2 KiB
Plaintext
152 lines
4.2 KiB
Plaintext
---
|
|
id: beta
|
|
title: Beta Features
|
|
sidebar_label: 🍼 Beta Features
|
|
---
|
|
|
|
import Tabs from "@theme/Tabs";
|
|
import TabItem from "@theme/TabItem";
|
|
|
|
## Tooltips
|
|
|
|
:::info
|
|
Due to limitations (or not having found a way just yet), this feature only works in `ZSH` and `PowerShell` for
|
|
the time being.
|
|
:::
|
|
|
|
Tooltips are segments that are rendered as a right-aligned prompt while you're typing certain keywords.
|
|
They behave similarly to the other segments when it comes to how and when they are shown so you can tweak
|
|
them to act and look like you want. The key difference is that they can be invoked using `tips` which are the
|
|
commands you are typing. Due to the possibility of the use of an alias, you can define for which keyword
|
|
the segment should be rendered.
|
|
|
|
### Configuration
|
|
|
|
You need to extend or create a custom theme with your tooltips. For example:
|
|
|
|
```json
|
|
{
|
|
"blocks": [
|
|
...
|
|
],
|
|
"tooltips": [
|
|
{
|
|
"type": "git",
|
|
"tips": ["git", "g"],
|
|
"style": "diamond",
|
|
"foreground": "#193549",
|
|
"background": "#fffb38",
|
|
"leading_diamond": "",
|
|
"trailing_diamond": "",
|
|
"properties": {
|
|
"display_status": true,
|
|
"display_upstream_icon": true,
|
|
"status_colors_enabled": true,
|
|
"local_changes_color": "#ff9248",
|
|
"ahead_and_behind_color": "#f26d50",
|
|
"behind_color": "#f17c37",
|
|
"ahead_color": "#89d1dc"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
This configuration will render a right-aligned git segment when you type `git` or `g` followed by a space. Keep in mind that
|
|
this is a blocking call, meaning that if the segment renders slow, you can't type until it's visible. Optimizations in this space
|
|
are being explored.
|
|
|
|
### Enable the feature
|
|
|
|
<Tabs
|
|
defaultValue="pwsh"
|
|
groupId="shell"
|
|
values={[
|
|
{ label: 'powershell', value: 'pwsh', },
|
|
{ label: 'zsh', value: 'zsh', },
|
|
]
|
|
}>
|
|
<TabItem value="pwsh">
|
|
|
|
Import/invoke Oh My Posh in your `$PROFILE` and add the following line below:
|
|
|
|
```pwsh
|
|
Enable-PoshTooltips
|
|
```
|
|
|
|
Restart your shell or reload your `$PROFILE` using `. $PROFILE` for the changes to take effect.
|
|
|
|
</TabItem>
|
|
<TabItem value="zsh">
|
|
|
|
Invoke Oh My Posh in `.zshrc` and add the following line below:
|
|
|
|
```bash
|
|
enable_poshtooltips
|
|
```
|
|
|
|
Restart your shell or reload `.zshrc` using `source ~/.zshrc` for the changes to take effect.
|
|
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
## Transient prompt
|
|
|
|
:::info
|
|
This feature only works in `powershell` for the time being.
|
|
:::
|
|
|
|
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.
|
|
|
|
### Configuration
|
|
|
|
You need to extend or create a custom theme with your transient prompt. For example:
|
|
|
|
```json
|
|
{
|
|
"blocks": {
|
|
...
|
|
}
|
|
"transient_prompt": {
|
|
"background": "transparent",
|
|
"foreground": "#ffffff",
|
|
"template": "{{ .Shell }}> <#f7dc66>{{ .Command }}</>"
|
|
}
|
|
}
|
|
```
|
|
|
|
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 }}> <#f7dc66>{{ .Command }}</>`
|
|
|
|
#### Template Properties
|
|
|
|
- `.Command`: `string` - the shell command you typed
|
|
- `.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
|
|
|
|
Import/invoke Oh My Posh in your `$PROFILE` and add the following line below:
|
|
|
|
```pwsh
|
|
Enable-PoshTransientPrompt
|
|
```
|
|
|
|
Restart your shell or reload your `$PROFILE` using `. $PROFILE` for the changes to take effect.
|
|
|
|
[go-text-template]: https://golang.org/pkg/text/template/
|
|
[sprig]: https://masterminds.github.io/sprig/
|
|
[console-title]: /docs/configure#console-title-template
|
|
[colors]: /docs/configure#colors
|