Ghostty Terminal: A Complete Setup Guide for Modern Mac Development

Ghostty Terminal: A Complete Setup Guide for Modern Mac Development

Ghostty is a cutting-edge terminal emulator that’s rapidly gaining popularity among developers and power users. Built with performance and customizability in mind, Ghostty offers a compelling alternative to other terminal emulators like Wezterm.

Key Features of Ghostty

GPU Acceleration

Ghostty leverages your computer’s GPU for rendering, resulting in smooth scrolling and excellent performance, even with complex terminal outputs. This GPU acceleration ensures a responsive and fluid experience, especially when dealing with large amounts of text or running resource-intensive tasks.

Native UI

Unlike some cross-platform terminals that use custom or web-based UIs, Ghostty focuses on a platform-native GUI. On Linux, it uses GTK4/libadwaita, while on macOS, it employs Swift, AppKit, and SwiftUI. This approach ensures that Ghostty feels integrated with your operating system, providing a seamless user experience.

Lua Configuration

Similar to Wezterm, Ghostty allows you to configure it using a simple key-value pair syntax in a configuration file. This flexibility enables users to customize their terminal environment to suit their specific needs and preferences.

Built-in Multiplexer

Ghostty includes built-in multiplexing capabilities, allowing you to manage multiple terminal sessions within a single window. This feature eliminates the need for external tools like tmux for many users.

Rich Color Support

The terminal supports 24-bit true color and offers a wide range of color schemes out of the box. With over 100 built-in themes and support for custom ones, you can easily personalize your terminal’s appearance.

Image Support

Ghostty supports the Kitty Graphics Protocol, allowing you to display images directly in the terminal. This can be particularly useful for certain workflows or for adding visual elements to your terminal environment.

Performance

Ghostty is built using the Zig programming language, which contributes to its impressive speed. Recent benchmarks place Ghostty as one of the fastest terminals for reading and displaying large Unicode files. In a comparison of popular terminal emulators, Ghostty ranked second in speed, only slightly behind Alacritty:

TerminalVersionSpeed
Ghostty173ms
Alacritty0.13.166ms
WezTerm20240203140ms

Unique Features

Terminal Inspector

One of Ghostty’s standout features is its Terminal Inspector. This real-time debugging tool allows you to peer into every detail of your terminal’s activity, from keystrokes to render timings. It’s an invaluable tool for understanding and optimizing your terminal usage.

Shaders

Ghostty supports custom shaders, allowing you to apply visual effects to your terminal. Whether you want a subtle glow or a retro CRT effect, shaders let you customize the visual atmosphere of your terminal environment.

Installation and Configuration

Ghostty Install

You can download Ghostty as a package on your Mac or you can install it with homebrew with:

brew install --cask ghostty

Install Meslo Nerd Font

Nerd Fonts are a collection of fonts that have been patched with a high number of glyphs (icons). They’re particularly useful for developers as they include many programming-related icons that can enhance your terminal and text editor experience.

To install the Meslo Nerd Font using Homebrew, run the following command:

brew install font-meslo-lg-nerd-font

This command does the following:

  1. It uses Homebrew to install the Meslo LG Nerd Font.
  2. The font will be downloaded and installed in your system’s font directory.

After running this command, the font should be available for use in Ghostty and other applications on your Mac.

To verify that the font was installed correctly, you can check your Font Book application or use it in an application that allows font selection.

It’s worth noting that you may need to restart Ghostty or any other applications where you want to use this font after installation.

The Meslo Nerd Font is an excellent choice for terminal use as it’s clear, easily readable, and includes a wide range of glyphs that can be useful in command-line interfaces and programming environments.

In the next section, we’ll configure Ghostty to use this newly installed font.

Setup Ghostty Config File

To set up the Ghostty config file with the specified settings, follow these steps:

  1. Create or open the Ghostty configuration file:
touch ~/.config/ghostty/config
vim ~/.config/ghostty/config
  1. Add the following configuration to the file:
font-family = MesloLGS Nerd Font Mono
font-size = 19
background-opacity = 0.9
theme = Argonaut

This configuration does the following:

  • Sets the font family to MesloLGS Nerd Font Mono. To list the fonts that are available in ghostty you can run the bellow command:
    ghostty +list-fonts
  • Changes the font size to 19
  • Sets the background opacity to 0.9 (90% opaque)
  • Applies the Argonaut color theme. To list the themes that are available in ghostty you can run the bellow command:
    ghostty +list-themes

After saving this configuration and restarting Ghostty, you should see the changes take effect. The terminal will now have a slightly transparent background, larger text, and the Argonaut color scheme.

Note that Ghostty uses a simple key-value pair syntax for its configuration, making it easy to understand and modify. You can further customize your Ghostty environment by adding more options to this config file as needed.

Install powerlevel10k theme

Powerlevel10k is a highly customizable theme for Zsh that emphasizes speed, flexibility, and out-of-the-box experience. It’s designed to make your command line informative and visually appealing without sacrificing performance.

To install Powerlevel10k using Homebrew, run the following commands:

brew install powerlevel10k
echo "source $(brew --prefix)/share/powerlevel10k/powerlevel10k.zsh-theme" >> ~/.zshrc

Let’s break down what these commands do:

  1. The first command installs Powerlevel10k using Homebrew.
  2. The second command adds a line to your .zshrc file that sources the Powerlevel10k theme. This ensures that the theme is loaded every time you start a new Zsh session.

After running these commands, you need to apply the changes to your current session:

source ~/.zshrc

This command reloads your Zsh configuration, applying the Powerlevel10k theme.

When you first run this, you’ll likely be greeted with the Powerlevel10k configuration wizard. This interactive process allows you to customize various aspects of your prompt, including:

  • The style of the prompt
  • Which segments to display (git status, time, etc.)
  • Color scheme
  • Icons and glyphs

Follow the on-screen instructions to set up Powerlevel10k according to your preferences. Don’t worry if you’re not sure about some options – you can always reconfigure later by running p10k configure.

Once configured, you’ll have a highly informative and visually appealing prompt that can show git status, execution time of commands, and much more, all while maintaining excellent performance.

Remember, you can always fine-tune your Powerlevel10k configuration by editing the ~/.p10k.zsh file that was created during the configuration process.

Setup zsh-autosuggestions plugin

Zsh-autosuggestions is a powerful plugin that suggests commands as you type based on your command history and completions. It can significantly speed up your command-line workflow by reducing the amount of typing needed for frequently used commands.

For a more detailed guide on enabling command autocomplete in Zsh, check out this article: Enable Command Autocomplete in Zsh

To install zsh-autosuggestions using Homebrew, run the following commands:

brew install zsh-autosuggestions
echo "source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh" >> ~/.zshrc
source ~/.zshrc

Let’s break down these commands:

  1. The first command installs the zsh-autosuggestions plugin using Homebrew.
  2. The second command adds a line to your .zshrc file that sources the zsh-autosuggestions plugin. This ensures that the plugin is loaded every time you start a new Zsh session.
  3. The third command reloads your Zsh configuration, applying the changes immediately.

After running these commands, you should see autosuggestions appear as you type in your terminal. The suggestions will be shown in a faded gray color. To accept a suggestion, you can typically press the right arrow key or End key.

You can customize the behavior of zsh-autosuggestions by adding configuration options to your .zshrc file. For example, you can change the color of the suggestions or modify the key bindings used to accept suggestions.

With zsh-autosuggestions set up, you’ll find that entering commands becomes faster and more efficient, especially for long or complex commands that you use frequently.

Setup zsh-syntax-highlighting

Zsh-syntax-highlighting is a plugin that provides syntax highlighting for the shell zsh. It enables highlighting of commands while they are typed at a zsh prompt into an interactive terminal. This helps in catching syntax errors, missing quotes, and other common mistakes before executing a command.

For a more comprehensive guide on enabling syntax highlighting in Zsh, check out this article: Enable Syntax Highlighting in Zsh

To install zsh-syntax-highlighting using Homebrew, run the following commands:

brew install zsh-syntax-highlighting
echo "source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ~/.zshrc
source ~/.zshrc

Let’s break down these commands:

  1. The first command installs the zsh-syntax-highlighting plugin using Homebrew.
  2. The second command adds a line to your .zshrc file that sources the zsh-syntax-highlighting plugin. This ensures that the plugin is loaded every time you start a new Zsh session.
  3. The third command reloads your Zsh configuration, applying the changes immediately.

After running these commands, you should see syntax highlighting in your terminal as you type commands. Typically, correctly typed commands will appear in green, while errors or unknown commands will appear in red.

Some key features of zsh-syntax-highlighting include:

  • Command highlighting: Valid commands are highlighted differently from invalid ones.
  • Option highlighting: Valid options for commands are highlighted.
  • Path highlighting: Existing file paths are underlined.
  • Bracket matching: Brackets are highlighted in pairs.

You can customize the colors and styles used by zsh-syntax-highlighting by adding configuration options to your .zshrc file. This allows you to tailor the appearance to your preferences or to match your terminal’s color scheme.

With zsh-syntax-highlighting set up, you’ll find it easier to spot and correct mistakes in your commands before executing them, leading to a more efficient and error-free command-line experience.

Enhance Ghostty with tmux and zoxide

While Ghostty is already a powerful terminal emulator, we can further enhance its capabilities by integrating it with tmux for advanced session management and zoxide for smarter directory navigation.

What is tmux and how can it help

Tmux (Terminal Multiplexer) is a powerful tool that allows you to create multiple terminal sessions within a single window. It’s particularly useful for:

  • Managing multiple terminal sessions
  • Running long processes in the background
  • Sharing terminal sessions with other users
  • Preserving your terminal setup across system reboots

To learn more about tmux and its basic usage, check out this guide: Tmux Basics

To install tmux using Homebrew, run:

brew install tmux

After installation, you can start a new tmux session by simply typing tmux in your terminal.

What is zoxide and how can it help

Zoxide is a smarter cd command that helps you navigate your filesystem more efficiently. It remembers which directories you use most frequently, so you can “jump” to them in just a few keystrokes.

Key features of zoxide include:

  • Faster navigation to frequently-used directories
  • Fuzzy matching for directory names
  • Integration with common shells and file managers

For a detailed guide on using zoxide, refer to this article: Zoxide Guide

To install zoxide using Homebrew, run:

brew install zoxide

Then, add the following line to your ~/.zshrc file to initialize zoxide:

eval "$(zoxide init zsh)"

After restarting your shell or running source ~/.zshrc, you can start using zoxide. For example, use z instead of cd to navigate to directories.

By integrating tmux and zoxide with Ghostty, you’re creating a powerful, efficient terminal environment. Tmux allows you to manage complex workflows with multiple panes and windows, while zoxide speeds up your navigation between projects and directories. Together with Ghostty’s GPU acceleration and customizability, you’ll have a terminal setup that significantly boosts your productivity.

Known Ghostty Erros

’xterm-ghostty’: unknown terminal type

When I try to run top on a bash Linux 6 environment I get the error: 'xterm-ghostty': unknown terminal type. To fix that I just do in the session:

export TERM=xterm-256color

You can add that in your .bashrc if you have only a couple of servers I have thousands :)

echo "export TERM=xterm-256color" >> ~/.bashrc
source ~/.bashrc

Conclusion

Ghostty represents a new generation of terminal emulators, combining performance, customizability, and modern features. Its focus on native UI, GPU acceleration, and innovative tools like the Terminal Inspector set it apart from other options. While it’s still in active development, Ghostty is already proving to be a powerful and flexible choice for users who demand more from their terminal emulator.

Whether you’re a developer, system administrator, or power user, Ghostty offers a compelling package that’s worth exploring. As it continues to evolve, it may well become the go-to terminal for those seeking the perfect blend of speed, features, and customization.