File: icat.rst

package info (click to toggle)
kitty 0.45.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,476 kB
  • sloc: ansic: 84,285; python: 57,992; objc: 5,432; sh: 1,333; xml: 364; makefile: 144; javascript: 78
file content (73 lines) | stat: -rw-r--r-- 2,756 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
icat
========================================

.. only:: man

    Overview
    --------------


*Display images in the terminal*

The ``icat`` kitten can be used to display arbitrary images in the |kitty|
terminal. Using it is as simple as::

    kitten icat image.jpeg

It supports all image types supported by `ImageMagick
<https://www.imagemagick.org>`__. It even works over SSH. For details, see the
:doc:`kitty graphics protocol </graphics-protocol>`.

You might want to create an alias in your shell's configuration files::

   alias icat="kitten icat"

Then you can simply use ``icat image.png`` to view images.

.. note::

    `ImageMagick <https://www.imagemagick.org>`__ must be installed for the
    full range of image types. Without it only PNG/JPG/GIF/BMP/TIFF/WEBP are
    supported.

.. note::

    kitty's image display protocol may not work when used within a terminal
    multiplexer such as :program:`screen` or :program:`tmux`, depending on
    whether the multiplexer has added support for it or not.


.. program:: kitty +kitten icat


The ``icat`` kitten has various command line arguments to allow it to be used
from inside other programs to display images. In particular, :option:`--place`,
:option:`--detect-support` and :option:`--print-window-size`.

If you are trying to integrate icat into a complex program like a file manager
or editor, there are a few things to keep in mind. icat normally works by communicating
over the TTY device, it both writes to and reads from the TTY. So it is
imperative that while it is running the host program does not do any TTY I/O.
Any key presses or other input from the user on the TTY device will be
discarded. If you would instead like to use it just as a backend to generate
the escape codes for image display, you need to pass it options to tell it the
window dimensions, where to place the image in the window and the transfer mode
to use. If you do that, it will not try to communicate with the TTY device at
all. The requisite options are: :option:`--use-window-size`, :option:`--place`
and :option:`--transfer-mode`, :option:`--stdin=no`.
For example, to demonstrate usage without access to the TTY:

.. code:: sh

   zsh -c 'setsid kitten icat --stdin=no --use-window-size $COLUMNS,$LINES,3000,2000 --transfer-mode=file myimage.png'

Here, ``setsid`` ensures icat has no access to the TTY device.
The values, 3000, 2000 are made up. They are the window width and height in
pixels, to obtain which access to the TTY is needed.

To be really robust you should consider writing proper support for the
:doc:`kitty graphics protocol </graphics-protocol>` in the program instead.
Nowadays there are many libraries that have support for it.


.. include:: /generated/cli-kitten-icat.rst