Skip to content

Add support for terminal tooltips escape sequence #279236

@Zezombye

Description

@Zezombye

In modern terminals, hyperlinks can be created with the OSC 8 escape sequence, such as:

echo -e '\e]8;;Time: 11:28\nLast cmd took 34s\nLast exit code is 0\aThis is a link\e]8;;\a'

As discussed here, I propose a new OSC escape sequence for tooltips (for example, OSC 150 which doesn't seem to be used).

This would make it such that

echo -e '\e]150;;Time: 11:28\nLast cmd took 34s\nLast exit code is 0\auser@hostname\e]150;;\a'

would display a user@hostname prompt, but upon hovering, extra info is displayed.

  • The syntax would be the exact same as OSC 8 which is detailed here, apart from the different OSC number.
  • The encoding would still be URL encoding, to be able to put special characters (especially newlines) in the tooltip. The terminal emulator must support newlines in the tooltip.
  • Unlike hyperlinks, tooltips do not cause security risks; therefore, if displayed, the dotted underline must be able to be disabled with the CSI 24 m escape code. Terminal emulators can also not display an underline at all by default.
  • Usage would be in shell prompts to not make them too cluttered, as well as help tooltips (such as extended error descriptions). Obviously, it would be up to the program's author to handle the case where terminal emulators wouldn't display the tooltip, and not put crucial info in it.

The current hyperlink feature cannot serve as a replacement for tooltips:

  • The newline is not properly rendered in VS Code's terminal or in Windows 11's terminal.
  • Windows 11's terminal warns that this is an "invalid link", while VS Code's terminal prompts to "ctrl+click" (which does nothing).
  • For security reasons, there is no way of disabling the hyperlink underline.

If implemented, terminal emulators which implement hyperlinks could trivially implement tooltips by reusing the same code (displaying extra text upon hover).

This is a draft, so please give your feedback :)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions