A modern terminal emulator

Command Line – kitty

© Photo by Sereja Ris on Unsplash

© Photo by Sereja Ris on Unsplash

Article from Issue 260/2022
Author(s):

Kitty, a terminal emulator by the creator of Calibre, promises customization and graphical acceleration at the command line.

Kovid Goyal is best known as the creator of Calibre, an ebook management application so far reaching that, despite a poor interface, it has become the definitive tool in its class. However, for the past five years, Goyal has also been developing kitty [1], a terminal emulator for the modern age, with features that range from text formatting and tiling to graphical acceleration. While kitty's list of features is intriguing, whether kitty can repeat the success of Calibre remains to be seen (Figure 1).

Figure 1: Kitty is a modern rethinking of the terminal emulator.

Versions of kitty are available in many Linux distributions, as well as for macOS and some BSDs. Installing from your distribution's package has the advantage of automatically integrating kitty with your environment. However, as with Calibre, new versions are released every three to six weeks, so users who want the most advanced version should download precompiled binaries (Figure 2) to their regular account with:

curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin
Figure 2: Kitty is in rapid development, so install kitty's available binaries rather than the package in your distribution's repository.

If you'd prefer an overnight build, use:

curl -L https://sw.kovidgoyal.net/kitty/installer.sh |sh /dev/stdin \ installer=nightly

To install the overnight build without overwriting an existing installation, add dest=DIRECTORY at the end of the command.

In both cases, the files to run kitty are installed to ~/.local/kitty.app. For convenience, you can incorporate kitty into your path, desktop, and file manager by running the series of commands shown in Listing 1.

Listing 1

Integrating kitty

 

Alternatively, you can simply download the latest version each time you want to experiment with kitty. A new download opens kitty. Keep in mind that at kitty's current stage of development, some users may not want to use kitty for regular work.

Configuring kitty

Kitty has all the features you would expect in a modern terminal emulator, including multiple command prompts, tabs, background opacity, and fonts. However, many of these features are far more elaborate than in standard emulators. For example, fonts can be set separately for individual characters, by pixel or points, line height, or column width, and can be mapped to any Unicode symbol. Font ligatures are enabled by default, but they can be disabled, and letters can be mapped to use special features, such as zero with a slash through it to distinguish it from a capital O. In short, most of the features available via HarfBuzz's font-rendering engine are available for Latin characters in kitty. Other features have their own numerous details. For instance, cursors can be set for color, size, and shape, while the size and display of the scrollback history can be adjusted for each prompt. You can set many of these features in kitty.conf, the configuration file, by pressing Ctrl+Shift+Escape (Figure 3).

Figure 3: kitty.conf consists of dozens of heavily commented fields for customization.

Others features can be set with keyboard shortcuts, such as Ctrl+Shift+Equal to increase font size and Ctrl+Shift+Minus to decrease font size. A long list of keyboard shortcuts is also available to navigate between prompts, tabs, and windows.

One especially important configuration option lets you choose from seven different layouts for multiple windows:

  • Fat: One or more full-width windows on top of the screen, the rest side by side at the bottom
  • Grid: All windows tiled
  • Horizontal: All windows side by side
  • Splits: Windows in arbitrary patterns created by horizontal and vertical splits
  • Stacked: One single maximized window displays at a time
  • Tall: One or more windows are shown full height on the left, the rest one below the other on the right
  • Vertical: All windows displayed horizontally

Users can cycle through layouts with Ctrl+Shift+L. In kitty.conf, the default layout can be set and others disabled.

A Grab Bag of Features

Few aspects of terminal emulators are left untouched by kitty. To list and explain them all would take a small book. Judging by the online help, it would also be pointless because right now kitty's emphasis is on development rather than documentation, and a given statement could soon become obsolete. However, here are a few of kitty's most convenient features:

  • Set tab title (Ctrl+Shift+Alt+T) – useful when numerous command lines are open (Figure 4)
Figure 4: Each terminal can be named for ease of navigation.
  • Open URL in web browser (Ctrl+Shift+E) – must be full URL (Figure 5)
Figure 5: Full URLs in kitty can be opened in a browser, which can be especially useful in comments.
  • Control from scripts or remotely [2]
  • Launch programs in a specific window or tab set in kitty.conf [3]
  • Text drag and drop (Figure 5)
  • Opening the scrollback history in less for easier analysis
  • Mark text on screen using regular expressions

In addition, kitty is built modularly, which makes creating extensions easy. Kitty calls extensions kittens [4]. Existing kittens include:

  • icat – displays images in the terminal
  • diff – a version of diff optimized for kitty
  • broadcast – typing something in one terminal displays it in other terminals
  • ssh – a version of SSH optimized for kitty
  • panel – a dock panel showing output from a kitty terminal

Already, kitty is encouraging extensive rethinking of the venerable terminal emulator.

Display and Performance Tweaks

By far its most important feature, kitty works efficiently with the system's GPU. Kitty caches all the font glyphs used in a session in video RAM, so latency (the time between typing a character and it appearing on the screen) is reduced and scrolling on the screen becomes faster. In kitty.conf, the repaint_delay, input_delay, and, sometimes, sync_to_monitor fields can be adjusted to find the ideal balance [5].

Hearing of this effort, many might dismiss these performance tweaks as minor. However, Goyal has posted a comparison table of computer terminals and their CPU usage online [5] (see Table 1). The CPU usage is surprising and obviously depends on circumstances, but using top, I have discovered that Plasma's Konsole is consistently in the top five apps for CPU usage, even when not in use. In fact, Konsole rivals Firefox and LibreOffice in the resources it consumes. Assuming that Goyal's other figures are also more or less correct, it seems absurd that terminal emulators should consume so many resources in an era when desktop environments are far more popular. Whatever else kitty does, reducing the consumption of resources seems a much overdue goal.

Table 1

Terminal Emulators and CPU Usage

Emulator

CPU Usage

kitty

6-8%

xterm

5-7% (but scrolling was extremely janky)

termite

10-13%

urxvt

12-14%

gnome-terminal

15-17%

konsole

29-31%

Source: Kovid Goyal [5]

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus