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
---
:::info
2022-09-17 04:41:52 -07:00
Due to limitations (or not having found a way just yet), this feature only works in `fish`, `zsh`, `powershell`
(`ConstrainedLanguage` mode unsupported) and `cmd` (as of [Clink][clink] v1.2.46+) for the time being.
2021-11-12 10:14:16 -08:00
:::
![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:
2023-03-31 11:55:36 -07:00
import Config from '@site/src/components/Config.js';
<Config data={{
"blocks": [],
2021-11-12 10:14:16 -08:00
"tooltips": [
{
"type": "git",
"tips": ["git", "g"],
"style": "diamond",
"foreground": "#193549",
"background": "#fffb38",
2022-09-16 07:32:48 -07:00
"leading_diamond": "\ue0b6",
"trailing_diamond": "\ue0b4",
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
}
}
]
2023-03-31 11:55:36 -07:00
}}/>
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.
2023-04-21 11:08:11 -07:00
A tip should not include any spaces. 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
2024-06-13 23:12:33 -07:00
Note that you can also define multiple tooltips for the same tip to compose tooltips for individual commands. For example,
this configuration will render the AWS profile as well as the Azure subscription information when you type `terraform`
followed by a space.
<Config data={{
"blocks": [],
"tooltips": [
{
"type": "aws",
"tips": ["aws", "terraform"],
"style": "plain",
"foreground": "#e0af68",
"template": "\uf0e0f {{.Profile}}{{if .Region}}@{{.Region}}{{end}}"
},
{
"type": "az",
"tips": ["az", "terraform"],
"style": "plain",
"foreground": "#b4f9f8",
"template": "\uebd8 {{ .Name }}"
}
]
}}/>
2021-11-18 04:15:35 -08:00
[clink]: https://chrisant996.github.io/clink/