oh-my-posh/website/docs/configuration/tooltips.mdx

111 lines
3 KiB
Plaintext
Raw Normal View History

2021-11-12 10:14:16 -08:00
---
2022-04-20 09:43:59 -07:00
id: tooltips
2021-11-12 10:14:16 -08:00
title: Tooltips
sidebar_label: Tooltips
---
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
:::info
2022-05-08 09:17:13 -07:00
Due to limitations (or not having found a way just yet), this feature only works in `fish`, `zsh`, `powershell` and `cmd` (as of [Clink][clink] v1.2.46+) for
2021-11-12 10:14:16 -08:00
the time being.
:::
![Tooltip Demo](/img/posh-tooltip.gif)
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
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
...
],
"tooltips": [
{
"type": "git",
"tips": ["git", "g"],
"style": "diamond",
"foreground": "#193549",
"background": "#fffb38",
"leading_diamond": "",
"trailing_diamond": "",
2022-03-27 01:12:47 -07:00
"template": "{{ .HEAD }}{{ if .Staging.Changed }} \uF046 {{ .Staging.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Working.Changed }} \uF044 {{ .Working.String }}{{ end }}",
2021-11-12 10:14:16 -08:00
"properties": {
"fetch_status": true,
2022-03-27 01:12:47 -07:00
"fetch_upstream_icon": true
2021-11-12 10:14:16 -08:00
}
}
]
}
```
2022-04-27 07:41:32 -07:00
This configuration will render a right-aligned git segment when you type `git` or `g` followed by a space.
A tip should not include any leading or trailing space but an interpolated one can be used, e.g., `g s`.
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.
2021-11-12 10:14:16 -08:00
## Enable the feature
<Tabs
defaultValue="pwsh"
groupId="shell"
values={[
{ label: 'powershell', value: 'pwsh', },
{ label: 'zsh', value: 'zsh', },
2022-03-22 11:53:37 -07:00
{ label: 'fish', value: 'fish', },
2021-11-12 10:14:16 -08:00
]
}>
<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-PoshTooltips
```
For example:
2021-11-13 04:30:41 -08:00
```powershell
2021-11-12 10:14:16 -08:00
# $PROFILE
2022-03-25 11:03:37 -07:00
oh-my-posh init pwsh --config ~\wildertheme.json | Invoke-Expression
2021-11-12 10:14:16 -08:00
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 `exec zsh` for the changes to take effect.
2021-11-12 10:14:16 -08:00
2022-03-22 11:53:37 -07:00
</TabItem>
<TabItem value="fish">
Invoke Oh My Posh in `~/.config/fish/config.fish` and add the following line below:
```bash
enable_poshtooltips
```
Restart your shell or reload fish using `exec fish` for the changes to take effect.
2021-11-12 10:14:16 -08:00
</TabItem>
</Tabs>
2021-11-18 04:15:35 -08:00
[clink]: https://chrisant996.github.io/clink/