Skip to content

Commit

Permalink
Add auto-detection for ghostty to support Kitty protocol.
Browse files Browse the repository at this point in the history
Fixes #121
  • Loading branch information
hzeller committed Dec 8, 2023
1 parent 2c725d9 commit 790519b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/term-query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,14 @@ TermGraphicsInfo QuerySupportedGraphicsProtocol() {
result.known_broken_sixel_cursor_placement = false;
result.in_tmux = false;

// Environment variables can be changed, so guesses from environment
// variables are just that: guesses.
// They will help as a fallback if the [>q query does not work.
// Only testing environment variables with very specific content.

const char *const term = getenv("TERM");
if (term && strcmp(term, "xterm-kitty") == 0) {
if (term && ((strcmp(term, "xterm-kitty") == 0) ||
(strcmp(term, "xterm-ghostty") == 0))) {
result.preferred_graphics = GraphicsProtocol::kKitty;
// Fall through, as we still have to determine if we're in tmux
}
Expand Down Expand Up @@ -235,6 +241,9 @@ TermGraphicsInfo QuerySupportedGraphicsProtocol() {
if (contains(data, len, "kitty")) {
result.preferred_graphics = GraphicsProtocol::kKitty;
}
if (contains(data, len, "ghostty")) {
result.preferred_graphics = GraphicsProtocol::kKitty;
}
if (contains(data, len, "mlterm")) {
result.preferred_graphics = GraphicsProtocol::kSixel;
}
Expand Down

0 comments on commit 790519b

Please sign in to comment.