mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-10 13:04:04 -08:00
57 lines
2 KiB
Plaintext
57 lines
2 KiB
Plaintext
---
|
|
id: tooltips
|
|
title: Tooltips
|
|
sidebar_label: Tooltips
|
|
---
|
|
|
|
import Tabs from "@theme/Tabs";
|
|
import TabItem from "@theme/TabItem";
|
|
|
|
:::info
|
|
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
|
|
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": "",
|
|
"template": "{{ .HEAD }}{{ if .Staging.Changed }} \uF046 {{ .Staging.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Working.Changed }} \uF044 {{ .Working.String }}{{ end }}",
|
|
"properties": {
|
|
"fetch_status": true,
|
|
"fetch_upstream_icon": true
|
|
}
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
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.
|
|
|
|
[clink]: https://chrisant996.github.io/clink/
|