Skip to main content

Configuration API

The libghostty configuration API provides functions for creating, loading, and managing terminal configuration.

Creating Configuration

ghostty_config_new

Creates a new configuration object with default values.
Returns: A new configuration object that must be freed with ghostty_config_free(). Example:

ghostty_config_free

Frees a configuration object.
config
ghostty_config_t
required
The configuration object to free.
Example:

ghostty_config_clone

Creates a deep copy of a configuration object.
config
ghostty_config_t
required
The configuration to clone.
Returns: A new configuration object with the same settings. Example:

Loading Configuration

ghostty_config_load_default_files

Loads configuration from default file locations.
config
ghostty_config_t
required
The configuration object to load into.
Searches for configuration files in these locations (in order):
  1. $XDG_CONFIG_HOME/ghostty/config (or ~/.config/ghostty/config if XDG_CONFIG_HOME is not set)
  2. Platform-specific locations
Example:

ghostty_config_load_file

Loads configuration from a specific file.
config
ghostty_config_t
required
The configuration object to load into.
path
const char*
required
Path to the configuration file.
Example:

ghostty_config_load_cli_args

Loads configuration from command-line arguments.
config
ghostty_config_t
required
The configuration object to load into.
Parses command-line arguments passed to ghostty_init() and applies them to the configuration. Example:

ghostty_config_load_recursive_files

Loads configuration from files recursively (e.g., imports).
config
ghostty_config_t
required
The configuration object to load into.
Processes any import directives in the configuration files.

ghostty_config_finalize

Finalizes the configuration, applying defaults and validating settings.
config
ghostty_config_t
required
The configuration object to finalize.
You must call this function after loading all configuration sources and before using the configuration.
Example:

Querying Configuration

ghostty_config_get

Retrieves a configuration value by key.
config
ghostty_config_t
required
The configuration object to query.
result
void*
required
Pointer to store the result. The type depends on the configuration key.
key
const char*
required
The configuration key name.
key_len
uintptr_t
required
Length of the key string.
Returns: true if the key exists and was retrieved successfully, false otherwise. Example:

ghostty_config_trigger

Retrieves the trigger (keybinding) for an action.
config
ghostty_config_t
required
The configuration object to query.
action
const char*
required
The action name.
action_len
uintptr_t
required
Length of the action string.
Returns: The input trigger for the action. Example:

Diagnostics

ghostty_config_diagnostics_count

Returns the number of configuration diagnostics (errors/warnings).
config
ghostty_config_t
required
The configuration object to check.
Returns: Number of diagnostics.

ghostty_config_get_diagnostic

Retrieves a diagnostic message by index.
config
ghostty_config_t
required
The configuration object to query.
index
uint32_t
required
Index of the diagnostic (0-based).
Returns: The diagnostic message. Example:

Utilities

ghostty_config_open_path

Returns the path to the configuration file that would be opened.
Returns: A string containing the configuration file path. Must be freed with ghostty_string_free(). Example:

Configuration Types

ghostty_config_color_list_s

A list of colors.
colors
const ghostty_config_color_s*
Pointer to array of colors.
len
size_t
Number of colors in the array.

ghostty_config_palette_s

A 256-color palette.
colors
ghostty_config_color_s[256]
Array of 256 colors (standard terminal color palette).

ghostty_config_command_list_s

A list of commands.

ghostty_quick_terminal_size_tag_e

Quick terminal size specification type.

ghostty_quick_terminal_size_s

Quick terminal size specification.

ghostty_config_quick_terminal_size_s

Quick terminal size configuration.
primary
ghostty_quick_terminal_size_s
Primary dimension (width for horizontal, height for vertical).
secondary
ghostty_quick_terminal_size_s
Secondary dimension (height for horizontal, width for vertical).

Complete Example

See Also