libghostty
Loading...
Searching...
No Matches
GhosttyTerminalSemanticPrompt Struct Reference

#include <ghostty/vt/terminal.h>

Data Fields

size_t size
GhosttySemanticPromptKind kind
GhosttySemanticPromptPromptKind prompt_kind
bool has_exit_code
int32_t exit_code
GhosttyString command
GhosttyString error

Detailed Description

A shell integration event, passed to the GHOSTTY_TERMINAL_OPT_SEMANTIC_PROMPT callback.

kind says which step of the command this is. The other fields only carry information for the kinds listed on each field, and are zero or empty otherwise.

Strings are only valid during the callback. Copy them if you need them later.

This is a sized struct. Later versions may add fields at the end, and size tells you which fields are present. Every field below has been present since this struct was introduced, so you only need to check size before reading fields added later. Two fields are likely to be added in the future:

  • An identifier the shell assigns to each command.
  • A flag on GHOSTTY_SEMANTIC_PROMPT_PROMPT_START that says the shell redrew a prompt it had already drawn, instead of starting a new one.

Neither exists yet.

Definition at line 1480 of file terminal.h.

Field Documentation

◆ command

GhosttyString command

The command line that is about to run, for GHOSTTY_SEMANTIC_PROMPT_OUTPUT_START. The shell sends it encoded, and this is the decoded text. Empty (len=0) if the shell didn't send one or it couldn't be decoded.

Definition at line 1506 of file terminal.h.

◆ error

A description of what went wrong, for GHOSTTY_SEMANTIC_PROMPT_COMMAND_END when the shell sent one. Empty (len=0) otherwise. Few shells send this. The exit code is the usual way to tell whether a command failed.

Definition at line 1512 of file terminal.h.

◆ exit_code

int32_t exit_code

The command's exit code. Only meaningful when has_exit_code is true. Exit codes can be negative, for example on Windows, so use has_exit_code rather than a special value to tell whether one was reported.

Definition at line 1500 of file terminal.h.

◆ has_exit_code

bool has_exit_code

True if the shell reported the command's exit code. Only ever true for GHOSTTY_SEMANTIC_PROMPT_COMMAND_END.

Definition at line 1494 of file terminal.h.

◆ kind

Which step of the command this event reports.

Definition at line 1485 of file terminal.h.

◆ prompt_kind

Which prompt is starting. Set for GHOSTTY_SEMANTIC_PROMPT_PROMPT_START. Always GHOSTTY_SEMANTIC_PROMPT_PROMPT_PRIMARY for other kinds.

Definition at line 1490 of file terminal.h.

◆ size

size_t size

Size of this struct in bytes.

Definition at line 1482 of file terminal.h.


The documentation for this struct was generated from the following file: