Kitty: Difference between revisions

From ArchWiki
(Update Interlanguage link)
m (Corrected it's to its)
 
(31 intermediate revisions by 16 users not shown)
Line 2: Line 2:
[[Category:Terminal emulators]]
[[Category:Terminal emulators]]
[[Category:Terminal multiplexers]]
[[Category:Terminal multiplexers]]
[[de:Kitty]]
[[ja:Kitty]]
[[ja:Kitty]]
[[pt:Kitty]]
[[pt:Kitty]]
Line 7: Line 8:
[[zh-hans:Kitty]]
[[zh-hans:Kitty]]
[https://sw.kovidgoyal.net/kitty/index.html kitty] is a scriptable OpenGL based terminal emulator with TrueColor, ligatures support, protocol extensions for keyboard input and image rendering. It also offers tiling capabilities, like [[GNU Screen]] or [[tmux]].
[https://sw.kovidgoyal.net/kitty/index.html kitty] is a scriptable OpenGL based terminal emulator with TrueColor, ligatures support, protocol extensions for keyboard input and image rendering. It also offers tiling capabilities, like [[GNU Screen]] or [[tmux]].
kitty is relatively new, of which first release ([https://github.com/kovidgoyal/kitty/releases/tag/v0.1.0 v0.1.0]) was in Feb 2017. It however does not mean it is still premature.


== Installation ==
== Installation ==


[[Install]] the {{Pkg|kitty}} package.
[[Install]] the {{Pkg|kitty}} package or {{AUR|kitty-git}} for the development version.


== Usage ==
== Usage ==
Line 22: Line 21:
=== Kittens ===
=== Kittens ===


kitty has a framework for creating subprograms called [https://sw.kovidgoyal.net/kitty/#kittens kittens]. Some of them:
kitty has a framework for creating subprograms called [https://sw.kovidgoyal.net/kitty/kittens_intro/ kittens]. The commands for all kittens are prefixed with {{ic|kitty +kitten}}, so it is convenient to use them as shell aliases.
 
==== icat ====
 
This kitten is based on the [https://sw.kovidgoyal.net/kitty/graphics-protocol/ kitty graphics protocol]. It needs [[ImageMagick]] to be installed. To show an image in the terminal:
 
$ kitty +kitten icat image.jpg
 
It can also display animated gifs in the terminal. Instead of an image file, you can pass a directory or an image url. This also works over ssh to display images from a remote server. Several applications such as [[ranger]] and {{Pkg|neofetch}} use this protocol for displaying images in the terminal. For more information, see the [https://sw.kovidgoyal.net/kitty/kittens/icat/ official documentation]
 
==== diff ====
 
This kitten requires either [[git]] or {{Pkg|diffutils}} to be installed. Optionally, install {{Pkg|python-pygments}} for syntax highlighting. To show a diff of two files:
 
$ kitty +kitten diff file1 file2
 
It displays diffs for images as well as text files. This kitten can also be used over ssh. You can pass directories instead of files for a recursive diff. For more information, see the [https://sw.kovidgoyal.net/kitty/kittens/diff/ official documentation].
 
==== clipboard ====


$ kitty +kitten icat image.jpeg            # show image in the terminal (needs imagemagick)
This kitten is used to read and write to the system clipboard and can be used to work with a clipboard even over ssh. To copy stdin to the system clipboard:
  $ kitty +kitten diff file1 file2            # show diff of two files
 
  $ kitty +kitten clipboard                   # this kitten allows working with clipboard even over ssh
  $ echo "Hello" | kitty +kitten clipboard
 
To output the current clipboard contents to stdout:
 
  $ kitty +kitten clipboard --get-clipboard
 
This command will show a permission popup by default. To disable this, edit the [https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.clipboard_control {{ic|clipboard_control}}] option in the configuration file:
 
{{hc|~/.config/kitty/kitty.conf|
clipboard_control write-clipboard read-clipboard}}
 
For more information, see the [https://sw.kovidgoyal.net/kitty/kittens/clipboard/ official documentation].


== Configuration ==
== Configuration ==


kitty is configurable in {{ic|~/.config/kitty/kitty.conf}}. Fonts, colors, cursors and scrollback behaviors can be adjusted. You can see available options in the [https://sw.kovidgoyal.net/kitty/conf.html official documentation]. Also you can find there [https://sw.kovidgoyal.net/kitty/conf.html#sample-kitty-conf configuration file] used by default.
kitty stores its configuration in {{ic|~/.config/kitty/kitty.conf}} and the default configuration can be found at {{ic|/usr/share/doc/kitty/kitty.conf}}. Fonts, colors, cursors and scrollback behaviors can be adjusted. You can see all available options in the [https://sw.kovidgoyal.net/kitty/conf.html official documentation] or {{man|5|kitty.conf}}.
 
{{Note|If you are editing the default configuration with vim, the sections will begin folded. Each section can be expanded by using {{ic|zo}} in normal mode.}}
 
{{Tip|
* The default configuration file at {{ic|/usr/share/doc/kitty/kitty.conf}} is self-documenting with comments explaining each option.
* The official documentation is available locally at {{ic|/usr/share/doc/kitty/html/index.html}}.
}}
 
== Tips and Tricks ==
 
=== Enable IME support ===
 
Kitty support for [[IBus]] IME framework is disabled by default. To enable it, set the [[environment variable]] {{ic|1=GLFW_IM_MODULE=ibus}}. This will also work with [[Fcitx5]] due to the compatible IBus interface that it offers.
 
=== Single instance mode ===
 
This works similar to a daemon mode. When kitty is launched with the {{ic|--single-instance}} or {{ic|-1}} option, only one instance of kitty will run. Launching kitty subsequently with the same option will create a new window of the existing kitty instance. This will lower memory usage because of a shared GPU cache and also reduces startup time. You can have multiple groups of kitty instances with {{ic|--instance group ''name''}} option. See {{man|1|kitty|single}} for more information.
 
== Troubleshooting ==
 
=== Terminal issues with SSH ===
 
When kitty is used to ssh into a remote that does not have its terminfo, various issues can occur. The solution is normally to copy over the terminfo. Kitty has an ssh kitten to automate exactly this.
 
$ kitty +kitten ssh ''user''@''host''
 
You may want to set it as an alias for {{ic|ssh}}. One way to do that is to detect if the user is using Kitty, and if so, alias the ssh command. To do that, you would append the following line to your {{ic|~/.bashrc}} or {{ic|~/.zshrc}} file:
 
{{bc|1=
<nowiki>[ "$TERM" = "xterm-kitty" ]</nowiki> && alias ssh="kitty +kitten ssh"
}}
 
If for whatever reason you are unable to install the terminfo on the remote, you can try setting {{ic|TERM}} to something that is more likely to be present. Note that this might disable some of the terminal's features. See [[OpenSSH#Connecting to a remote without the appropriate terminfo entry]].
 
=== Disappearing background color in vim ===
 
When using a color scheme with a background color in [[vim]], the background may disappear or flicker while scrolling. To fix this, make sure the environment variable {{ic|TERM}} is still set to {{ic|xterm-kitty}}, then add this line to your {{ic|.vimrc}} file:
 
{{hc|~/.vimrc|2=
let &t_ut=<nowiki>''</nowiki>
}}
 
Related bug reports: [https://github.com/kovidgoyal/kitty/issues/108 Github issue #108], [https://sw.kovidgoyal.net/kitty/faq/#using-a-color-theme-with-a-background-color-does-not-work-well-in-vim kitty FAQ]
 
=== Bitmap fonts not recognized ===
 
kitty does not provide support for bitmap fonts, due to its fundamental feature of being able to display fonts at arbitrary font sizes, which bitmap fonts are not suited for; see [https://github.com/kovidgoyal/kitty/issues/97 Github issue #97].


== See also ==
== See also ==


* [https://sw.kovidgoyal.net/kitty/ Official website]
* [https://github.com/kovidgoyal/kitty GitHub repository]
* [https://github.com/kovidgoyal/kitty GitHub repository]

Latest revision as of 19:54, 22 February 2024

kitty is a scriptable OpenGL based terminal emulator with TrueColor, ligatures support, protocol extensions for keyboard input and image rendering. It also offers tiling capabilities, like GNU Screen or tmux.

Installation

Install the kitty package or kitty-gitAUR for the development version.

Usage

New tabs and windows can be created and resized through various Ctrl+Shift shortcuts. Layouts are switchable through Ctrl+Shift+l and can be saved/restored.

A full keyboard mode provides distinction between ambiguous keys like Ctrl+i vs Tab. Moreover, new text effects like curly-underline are also available for applications that support it.

Kittens

kitty has a framework for creating subprograms called kittens. The commands for all kittens are prefixed with kitty +kitten, so it is convenient to use them as shell aliases.

icat

This kitten is based on the kitty graphics protocol. It needs ImageMagick to be installed. To show an image in the terminal:

$ kitty +kitten icat image.jpg

It can also display animated gifs in the terminal. Instead of an image file, you can pass a directory or an image url. This also works over ssh to display images from a remote server. Several applications such as ranger and neofetch use this protocol for displaying images in the terminal. For more information, see the official documentation

diff

This kitten requires either git or diffutils to be installed. Optionally, install python-pygments for syntax highlighting. To show a diff of two files:

$ kitty +kitten diff file1 file2

It displays diffs for images as well as text files. This kitten can also be used over ssh. You can pass directories instead of files for a recursive diff. For more information, see the official documentation.

clipboard

This kitten is used to read and write to the system clipboard and can be used to work with a clipboard even over ssh. To copy stdin to the system clipboard:

$ echo "Hello" | kitty +kitten clipboard

To output the current clipboard contents to stdout:

$ kitty +kitten clipboard --get-clipboard

This command will show a permission popup by default. To disable this, edit the clipboard_control option in the configuration file:

~/.config/kitty/kitty.conf
clipboard_control write-clipboard read-clipboard

For more information, see the official documentation.

Configuration

kitty stores its configuration in ~/.config/kitty/kitty.conf and the default configuration can be found at /usr/share/doc/kitty/kitty.conf. Fonts, colors, cursors and scrollback behaviors can be adjusted. You can see all available options in the official documentation or kitty.conf(5).

Note: If you are editing the default configuration with vim, the sections will begin folded. Each section can be expanded by using zo in normal mode.
Tip:
  • The default configuration file at /usr/share/doc/kitty/kitty.conf is self-documenting with comments explaining each option.
  • The official documentation is available locally at /usr/share/doc/kitty/html/index.html.

Tips and Tricks

Enable IME support

Kitty support for IBus IME framework is disabled by default. To enable it, set the environment variable GLFW_IM_MODULE=ibus. This will also work with Fcitx5 due to the compatible IBus interface that it offers.

Single instance mode

This works similar to a daemon mode. When kitty is launched with the --single-instance or -1 option, only one instance of kitty will run. Launching kitty subsequently with the same option will create a new window of the existing kitty instance. This will lower memory usage because of a shared GPU cache and also reduces startup time. You can have multiple groups of kitty instances with --instance group name option. See kitty(1) § single for more information.

Troubleshooting

Terminal issues with SSH

When kitty is used to ssh into a remote that does not have its terminfo, various issues can occur. The solution is normally to copy over the terminfo. Kitty has an ssh kitten to automate exactly this.

$ kitty +kitten ssh user@host

You may want to set it as an alias for ssh. One way to do that is to detect if the user is using Kitty, and if so, alias the ssh command. To do that, you would append the following line to your ~/.bashrc or ~/.zshrc file:

[ "$TERM" = "xterm-kitty" ] && alias ssh="kitty +kitten ssh"

If for whatever reason you are unable to install the terminfo on the remote, you can try setting TERM to something that is more likely to be present. Note that this might disable some of the terminal's features. See OpenSSH#Connecting to a remote without the appropriate terminfo entry.

Disappearing background color in vim

When using a color scheme with a background color in vim, the background may disappear or flicker while scrolling. To fix this, make sure the environment variable TERM is still set to xterm-kitty, then add this line to your .vimrc file:

~/.vimrc
let &t_ut=''

Related bug reports: Github issue #108, kitty FAQ

Bitmap fonts not recognized

kitty does not provide support for bitmap fonts, due to its fundamental feature of being able to display fonts at arbitrary font sizes, which bitmap fonts are not suited for; see Github issue #97.

See also