Ghostty — Workaround for Missing or Unsuitable Terminal xterm-ghostty

Published by Christian Mohn · Read in about 2 min (317 words)

Ghostty screenshot
The freshly made public Ghostty terminal emulator by Mitchell Hashimoto (co-founder of Hashicorp) is all the rage at the moment, and it definitely looks interesting:

Ghostty is a terminal emulator that differentiates itself by being fast, feature-rich, and native. While there are many excellent terminal emulators available, they all force you to choose between speed, features, or native UIs. Ghostty provides all three.

I decided to give it a spin on my Macbook, and see if it offers any improvements over Wezterm, which is my current terminal emulator of choice.

So far so good, it seems to work very well and offers quite a few customization options.

Tip

Also worth noting is ghostty.zerebos.com that offers a Ghostty config tool.

The first real issue I had with it, was when using SSH to connect to remote resources. This produced the missing or unsuitable terminal: xterm-ghostty error message, because the remote resource doesn’t have the xterm-ghostty terminfo defined. The official Ghostty docs has some workarounds for it, but these are either to convoluted like copying terminfo entries to all remote systems, or setting SetEnv TERM=xterm-256color in .ssh/config for each remote host. The other alternative is to set SetEnv TERM=xterm-256color system wide but that also affects other terminal emulators (as does setting it in .ssh/config)

Workaround #

My workaround for it, is to set the TERM variable in my .zsrc file, but only if Ghostty is the terminal emulator in use (as Wezterm doesn’t have this issue). This way I don’t have to do it for every remote host, or copy terminfo for Ghostty to them.

This is simple do to, as the $TERM_PROGRAM variable contains the name of the emulator currently in use. Add the following to your .zsrc file, and the TERM=xterm-256color variable declaration is only done when .zsrc is processed in Ghostty and not in other terminal emulators.

if [[ "$TERM_PROGRAM" == "ghostty" ]]; then
    export TERM=xterm-256color
fi
Post last updated on December 28, 2024: Update Ghostty-workaround-for-missing-or-unsuitable-terminal-xterm-ghostty.md

About

vNinja.net is the online hub of Christian Mohn and Stine Elise Larsen.

The site primarily focuses on IT architecture and data center technologies, with a strong emphasis on virtualization and related topics.
While the main content revolves around these areas, you'll also find a range of other subjects covered from time to time, reflecting the interests of authors.

Sponsors