chore: import official kitty sources from upstream
Bring the kovidgoyal/kitty codebase in as the base of FWS-Kitty, vendored at upstream commit 91fb38a without its git history.
This commit is contained in:
1134 files changed
+433629
No files matched your search
@@ -0,0 +1,30 @@
|
||||
broadcast
|
||||
==================================================
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
--------------
|
||||
|
||||
*Type text in all kitty windows simultaneously*
|
||||
|
||||
The ``broadcast`` kitten can be used to type text simultaneously in all
|
||||
:term:`kitty windows <window>` (or a subset as desired).
|
||||
|
||||
To use it, simply create a mapping in :file:`kitty.conf` such as::
|
||||
|
||||
map f1 launch --allow-remote-control kitten broadcast
|
||||
|
||||
Then press the :kbd:`F1` key and whatever you type in the newly created window
|
||||
will be sent to all kitty windows.
|
||||
|
||||
You can use the options described below to control which windows are selected.
|
||||
|
||||
For example, only broadcast to other windows in the current tab::
|
||||
|
||||
map f1 launch --allow-remote-control kitten broadcast --match-tab state:focused
|
||||
|
||||
.. program:: kitty +kitten broadcast
|
||||
|
||||
|
||||
.. include:: /generated/cli-kitten-broadcast.rst
|
||||
@@ -0,0 +1,220 @@
|
||||
Selecting files, fast
|
||||
========================
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
--------------
|
||||
|
||||
.. versionadded:: 0.45.0
|
||||
|
||||
.. only:: not man
|
||||
|
||||
.. figure:: /screenshots/choose-files.webp
|
||||
:alt: The choose files kitten, showing metadata and title from an e-book file
|
||||
:align: center
|
||||
:width: 100%
|
||||
|
||||
|
||||
The choose-files kitten is designed to allow you to select files, very fast,
|
||||
with just a few key strokes. It operates like `fzf
|
||||
<https://github.com/junegunn/fzf/>`__ and similar fuzzy finders, except that
|
||||
it is specialised for finding files. As such it supports features such as
|
||||
filtering by file type, file type icons, content previews and
|
||||
so on, out of the box. It can be used as a drop in (but much more efficient and
|
||||
keyboard friendly) replacement for the :guilabel:`File open and save`
|
||||
dialog boxes common to GUI programs. On Linux, with the help of the
|
||||
:doc:`desktop-ui </kittens/desktop-ui>` kitten, you can even convince
|
||||
most GUI programs on your computer to use this kitten instead of regular file
|
||||
dialogs.
|
||||
|
||||
Simply run it as::
|
||||
|
||||
kitten choose-files
|
||||
|
||||
to select a single file from the tree rooted at the current working directory.
|
||||
|
||||
Type a few letters from the filename and once it becomes the top selection,
|
||||
press :kbd:`Enter`. You can change the current directory by selecting a
|
||||
directory and pressing the :kbd:`Tab` key. :kbd:`Shift+Tab` goes up one
|
||||
directory level.
|
||||
|
||||
If you want to choose a file and insert it into your shell prompt at the
|
||||
current cursor position, press :sc:`insert_chosen_file` for files or
|
||||
:sc:`insert_chosen_directory` for directories. Similarly, to have a file
|
||||
chosen in a command line, use, for example::
|
||||
|
||||
some-command "$(kitten choose-files)"
|
||||
|
||||
Note that the above may not work in a complicated pipeline as it performs
|
||||
terminal I/O and needs exclusive access to the tty device while choosing a
|
||||
file.
|
||||
|
||||
.. note:: For content previews, this kitten uses some external programs. In
|
||||
particular `ffmpeg <https://www.ffmpeg.org/>`__ is needed for video
|
||||
previews and `calibre <https://calibre-ebook.com>`__ is needed
|
||||
for ebook metadata and cover preiews.
|
||||
|
||||
Creating shortcuts to favorite/frequently used directories
|
||||
------------------------------------------------------------
|
||||
|
||||
You can create keyboard shortcuts to quickly switch to any directory in
|
||||
:file:`choose-files.conf`. For example:
|
||||
|
||||
.. code-block:: conf
|
||||
|
||||
map ctrl+t cd /tmp
|
||||
map alt+p cd ~/my/project
|
||||
|
||||
Selecting multiple files
|
||||
-----------------------------
|
||||
|
||||
When you wish to select multiple files, start the kitten with :option:`--mode
|
||||
<kitty +kitten choose_files --mode>`:code:`=files`. Then instead of pressing
|
||||
:kbd:`Enter`, press :kbd:`Shift+Enter` instead and the file will be added to the list
|
||||
of selections. You can also hold the :kbd:`Ctrl` key and click on files to add
|
||||
them to the selections. Similarly, you can hold the :kbd:`Alt` key and click to
|
||||
select ranges of files (similar to using :kbd:`Shift+click` in a GUI app).
|
||||
Press :kbd:`Enter` on the last selected file to finish. The list of selected
|
||||
files is displayed at the bottom of the kitten and you can click on them
|
||||
to deselect a file. Similarly, pressing :kbd:`Shift+Enter` will un-select a
|
||||
previously selected file.
|
||||
|
||||
|
||||
Hidden and ignored files
|
||||
--------------------------
|
||||
|
||||
By default, the kitten does not process hidden files and directories (whose
|
||||
names start with a period). This can be :opt:`changed in the configuration <kitten-choose_files.show_hidden>`
|
||||
and also at runtime via the clickable link to the right of the search input.
|
||||
|
||||
Similarly, the kitten respects both :file:`.gitignore` and :file:`.ignore`
|
||||
files, by default. This can also be changed both :opt:`in configuration
|
||||
<kitten-choose_files.respect_ignores>` or at runtime. Note that
|
||||
:file:`.gitignore` files are only respected if there is also a :file:`.git`
|
||||
directory present. The kitten also supports the global :file:`.gitignore` file,
|
||||
though it applies only inside git working trees. You can specify :opt:`global ignore
|
||||
patterns <kitten-choose_files.ignore>`, that apply everywhere in :file:`choose-files.conf`.
|
||||
|
||||
|
||||
Selecting non-existent files (save file names)
|
||||
-------------------------------------------------
|
||||
|
||||
This kitten can also be used to select non-existent files, that is a new file
|
||||
for a :guilabel:`Save file` type of dialog using :option:`--mode <kitty +kitten
|
||||
choose_files --mode>`:code:`=save-file`. Once you have changed to the directory
|
||||
you want the file to be in (using the :kbd:`Tab` key),
|
||||
press :kbd:`Ctrl+Enter` and you will be able to type in the file name. If you
|
||||
wish to modify an existing file name use :kbd:`Alt+Enter` to modify the
|
||||
filename of the current top match instead.
|
||||
|
||||
|
||||
Selecting directories
|
||||
---------------------------
|
||||
|
||||
This kitten can also be used to select directories,
|
||||
for an :guilabel:`Open directory` type of dialog using :option:`--mode <kitty +kitten
|
||||
choose_files --mode>`:code:`=dir`. Once you have changed to the directory
|
||||
you want, press :kbd:`Ctrl+Enter` to accept it. Or if you are in a parent
|
||||
directory you can select a descendant directory by pressing :kbd:`Enter`, the
|
||||
same as you would for selecting a file to open.
|
||||
|
||||
|
||||
Selecting files or directories
|
||||
--------------------------------
|
||||
|
||||
To select any existing path, whether it is a file or a directory, use
|
||||
:option:`--mode <kitty +kitten choose_files --mode>`:code:`=all`. Press
|
||||
:kbd:`Enter` to select the highlighted path. You can still use :kbd:`Tab` to
|
||||
change into a highlighted directory and :kbd:`Ctrl+Enter` to select the
|
||||
current directory itself.
|
||||
|
||||
|
||||
Editing the search text
|
||||
----------------------------
|
||||
|
||||
The search/filter text box uses the same line editing engine as the shell
|
||||
prompt kitten, supporting the usual Emacs-style editing shortcuts such as
|
||||
:kbd:`Ctrl+A`/:kbd:`Ctrl+E` to move to the start/end of the text,
|
||||
:kbd:`Ctrl+Left`/:kbd:`Ctrl+Right` to move by a word, :kbd:`Ctrl+K`/:kbd:`Ctrl+U`
|
||||
to delete to the end/start of the line, :kbd:`Ctrl+W`/:kbd:`Alt+D` to delete
|
||||
the previous/next word and so on.
|
||||
|
||||
However, by default, the arrow keys as well as :kbd:`Home`, :kbd:`End`,
|
||||
:kbd:`Ctrl+Home` and :kbd:`Ctrl+End` are bound to actions that navigate the
|
||||
list of matched results, rather than moving the cursor within the search
|
||||
text, since that is the more frequently needed behavior when quickly
|
||||
filtering a list of files. If you prefer these keys to edit the search text
|
||||
instead, as in a regular text input, you can rebind them to one of the
|
||||
following actions in :file:`choose-files.conf`, which forward the key press
|
||||
to the search text editor:
|
||||
|
||||
.. list-table::
|
||||
:widths: auto
|
||||
:header-rows: 1
|
||||
|
||||
* - Action
|
||||
- Editing operation it performs
|
||||
* - :code:`edit_cursor_left`
|
||||
- Move the cursor one character to the left
|
||||
* - :code:`edit_cursor_right`
|
||||
- Move the cursor one character to the right
|
||||
* - :code:`edit_start_of_line`
|
||||
- Move the cursor to the start of the search text
|
||||
* - :code:`edit_end_of_line`
|
||||
- Move the cursor to the end of the search text
|
||||
* - :code:`edit_start_of_document`
|
||||
- Same as :code:`edit_start_of_line`, provided for symmetry with the shell prompt's line editor
|
||||
* - :code:`edit_end_of_document`
|
||||
- Same as :code:`edit_end_of_line`, provided for symmetry with the shell prompt's line editor
|
||||
* - :code:`edit_forward_word`
|
||||
- Move the cursor forward by one word
|
||||
* - :code:`edit_backward_word`
|
||||
- Move the cursor backward by one word
|
||||
* - :code:`edit_backspace`
|
||||
- Delete the character before the cursor
|
||||
* - :code:`edit_delete`
|
||||
- Delete the character after the cursor
|
||||
* - :code:`edit_kill_to_start_of_line`
|
||||
- Delete everything from the start of the line to the cursor
|
||||
* - :code:`edit_kill_to_end_of_line`
|
||||
- Delete everything from the cursor to the end of the line
|
||||
* - :code:`edit_kill_word_left`
|
||||
- Delete the word before the cursor
|
||||
* - :code:`edit_kill_word_right`
|
||||
- Delete the word after the cursor
|
||||
* - :code:`edit_yank`
|
||||
- Insert the most recently deleted text
|
||||
|
||||
For example, to make the arrow keys, :kbd:`Home` and :kbd:`End` edit the
|
||||
search text instead of navigating the results list::
|
||||
|
||||
map left edit_cursor_left
|
||||
map right edit_cursor_right
|
||||
map home edit_start_of_line
|
||||
map end edit_end_of_line
|
||||
map ctrl+home edit_start_of_document
|
||||
map ctrl+end edit_end_of_document
|
||||
|
||||
Note that :kbd:`Up`, :kbd:`Down` and other keys not listed above continue to
|
||||
be usable for navigating the results list even after applying the above
|
||||
overrides. Also note that any key not bound to an action at all is
|
||||
automatically forwarded to the search text editor, which is why keys such as
|
||||
:kbd:`Backspace`, :kbd:`Delete`, :kbd:`Ctrl+K`, :kbd:`Ctrl+W` etc. already
|
||||
edit the search text, without needing any of the above actions.
|
||||
|
||||
|
||||
Configuration
|
||||
------------------------
|
||||
|
||||
You can configure various aspects of the kitten's operation by creating a
|
||||
:file:`choose-files.conf` in your :ref:`kitty config folder <confloc>`.
|
||||
See below for the supported configuration directives.
|
||||
|
||||
|
||||
.. include:: /generated/conf-kitten-choose_files.rst
|
||||
|
||||
|
||||
.. include:: /generated/cli-kitten-choose_files.rst
|
||||
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
Changing kitty fonts
|
||||
========================
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
--------------
|
||||
|
||||
Terminal aficionados spend all day staring at text, as such, getting text
|
||||
rendering just right is very important. kitty has extremely powerful facilities
|
||||
for fine-tuning text rendering. It supports `OpenType features
|
||||
<https://en.wikipedia.org/wiki/List_of_typographic_features>`__ to select
|
||||
alternate glyph shapes, and `Variable fonts
|
||||
<https://en.wikipedia.org/wiki/Variable_font>`__ to control the weight or
|
||||
spacing of a font precisely. You can also :opt:`select which font is used to
|
||||
render particular unicode codepoints <symbol_map>` and you can :opt:`modify
|
||||
font metrics <modify_font>` and even :opt:`adjust the gamma curves
|
||||
<text_composition_strategy>` used for rendering text onto the background color.
|
||||
|
||||
The first step is to select the font faces kitty will use for rendering
|
||||
regular, bold and italic text. kitty comes with a convenient UI for choosing fonts,
|
||||
in the form of the *choose-fonts* kitten. Simply run::
|
||||
|
||||
kitten choose-fonts
|
||||
|
||||
and follow the on screen prompts.
|
||||
|
||||
First, choose the family you want, the list of families can be easily filtered by
|
||||
typing a few letters from the family name you are looking for. The family
|
||||
selection screen shows you a preview of how the family looks.
|
||||
|
||||
.. image:: ../screenshots/family-selection.png
|
||||
:alt: Choosing a family with the choose fonts kitten
|
||||
:width: 600
|
||||
|
||||
Once you select a family by pressing the :kbd:`Enter` key, you
|
||||
are shown previews of what the regular, bold and italic faces look like
|
||||
for that family. You can choose to fine tune any of the faces. Start with
|
||||
fine-tuning the regular face by pressing the :kbd:`R` key. The other styles
|
||||
will be automatically adjusted based on what you select for the regular face.
|
||||
|
||||
.. image:: ../screenshots/font-fine-tune.png
|
||||
:alt: Fine tune a font by choosing a precise weight and features
|
||||
:width: 600
|
||||
|
||||
You can choose a specific style or font feature by clicking on it. A precise
|
||||
value for any variable axes can be selected using the slider, in the screenshot
|
||||
above, the font supports precise weight adjustment. If you are lucky the font
|
||||
designer has included descriptive names for font features, which will be
|
||||
displayed, if not, consult the documentation of the font to see what each feature does.
|
||||
|
||||
.. _font_spec_syntax:
|
||||
|
||||
The font specification syntax
|
||||
--------------------------------
|
||||
|
||||
If you don't like the choose fonts kitten or simply want to understand and
|
||||
write font selection options into :file:`kitty.conf` yourself, read on.
|
||||
|
||||
There are four font face selection keys: `font_family`, `bold_font`,
|
||||
`italic_font` and `bold_italic_font`. Each of these supports the syntax
|
||||
described below. Their values can be of three types, either a
|
||||
font family name, the keyword ``auto`` or an extended ``key=value`` syntax
|
||||
for specifying font selection precisely.
|
||||
|
||||
If a font family name is specified kitty will use Operating System APIs to
|
||||
search for a matching font. The keyword ``auto`` means kitty will choose a font
|
||||
completely automatically, typically this is used for automatically selecting
|
||||
bold/italic variants once the :opt:`font_family` is set. The bold and italic
|
||||
variants will then automatically use the same set of features as the main face.
|
||||
|
||||
To specify font face selection more precisely, a ``key=value`` syntax is used.
|
||||
First, let's look at a few examples::
|
||||
|
||||
# Select by family only, actual face selection is automatic
|
||||
font_family family="Fira Code"
|
||||
# Select an exact face by Postscript name
|
||||
font_family postscript_name=FiraCode
|
||||
# Select an exact face by family with features and variable weight
|
||||
font_family family=SourceCodeVF variable_name=SourceCodeUpright features="+zero cv01=2" wght=380
|
||||
|
||||
The following are the known keys, any other keys are names of *variable axes*,
|
||||
that is, they are used to set the variable value for some font characteristic.
|
||||
|
||||
``family``
|
||||
A font family name. A family typically has multiple actual font faces, such
|
||||
as bold and italic variants. One or more of the faces can even be variable,
|
||||
allowing fine tuning of font characteristics.
|
||||
|
||||
``style``
|
||||
A style name to choose a particular font from a given family. Useful only
|
||||
with the ``family`` key, when no more precise methods for face selection
|
||||
are specified. Can also be used to specify a named variable style for
|
||||
variable fonts.
|
||||
|
||||
``postscript_name``
|
||||
The actual postscript name for a font face. This allows selecting a
|
||||
particular variant within a font family. But note that postscript names
|
||||
are usually insufficient for selecting variable fonts.
|
||||
|
||||
``full_name``
|
||||
This can be used to select a particular font face in a family. However, it
|
||||
is less precise than ``postscript_name`` and should not generally be used.
|
||||
|
||||
``variable_name``
|
||||
Some families with variable fonts actually contain multiple font files. For
|
||||
example, a family could have variable weights with one font file containing
|
||||
upright variable weight faces and another containing italic variable weight
|
||||
faces. Well designed fonts use a *variable name* to distinguish between
|
||||
such files. Should be used in conjunction with ``family`` to select a
|
||||
particular variable font file.
|
||||
|
||||
``features``
|
||||
A space separated list of OpenType font features to enable/disable or
|
||||
select a value of, for this font. Consult the documentation for the font
|
||||
family to see what features it supports and their effects. The exact syntax
|
||||
for specifying features is `documented by HarfBuzz
|
||||
<https://harfbuzz.github.io/harfbuzz-hb-common.html#hb-feature-from-string>`__
|
||||
|
||||
``system``
|
||||
This can be used to pass an arbitrary string, usually a family or full name
|
||||
to the OS font selection APIs. Should not be used in conjunction with any
|
||||
other keys. Is the same as specifying just the font name without any keys.
|
||||
|
||||
|
||||
In addition to these keys, any four letter key is treated as the name of a
|
||||
variable characteristic of the font. Its value is used to set the value for
|
||||
the name.
|
||||
@@ -0,0 +1,63 @@
|
||||
clipboard
|
||||
==================================================
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
--------------
|
||||
|
||||
*Copy/paste to the system clipboard from shell scripts*
|
||||
|
||||
.. highlight:: sh
|
||||
|
||||
|
||||
The ``clipboard`` kitten can be used to read or write to the system clipboard
|
||||
from the shell. It even works over SSH. Using it is as simple as::
|
||||
|
||||
echo hooray | kitten clipboard
|
||||
|
||||
All text received on :file:`STDIN` is copied to the clipboard.
|
||||
|
||||
To get text from the clipboard::
|
||||
|
||||
kitten clipboard --get-clipboard
|
||||
|
||||
The text will be written to :file:`STDOUT`. Note that by default kitty asks for
|
||||
permission when a program attempts to read the clipboard. This can be
|
||||
controlled via :opt:`clipboard_control`.
|
||||
|
||||
.. versionadded:: 0.27.0
|
||||
Support for copying arbitrary data types
|
||||
|
||||
The clipboard kitten can be used to send/receive
|
||||
more than just plain text from the system clipboard. You can transfer arbitrary
|
||||
data types. Best illustrated with some examples::
|
||||
|
||||
# Copy an image to the clipboard:
|
||||
kitten clipboard picture.png
|
||||
|
||||
# Copy an image and some text to the clipboard:
|
||||
kitten clipboard picture.jpg text.txt
|
||||
|
||||
# Copy text from STDIN and an image to the clipboard:
|
||||
echo hello | kitten clipboard picture.png /dev/stdin
|
||||
|
||||
# Copy any raster image available on the clipboard to a PNG file:
|
||||
kitten clipboard -g picture.png
|
||||
|
||||
# Copy an image to a file and text to STDOUT:
|
||||
kitten clipboard -g picture.png /dev/stdout
|
||||
|
||||
# List the formats available on the system clipboard
|
||||
kitten clipboard -g -m . /dev/stdout
|
||||
|
||||
Normally, the kitten guesses MIME types based on the file names. To control the
|
||||
MIME types precisely, use the :option:`--mime <kitty +kitten clipboard --mime>` option.
|
||||
|
||||
This kitten uses a new protocol developed by kitty to function, for details,
|
||||
see :doc:`/clipboard`.
|
||||
|
||||
.. program:: kitty +kitten clipboard
|
||||
|
||||
|
||||
.. include:: /generated/cli-kitten-clipboard.rst
|
||||
@@ -0,0 +1,155 @@
|
||||
Command palette
|
||||
=================
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
--------------
|
||||
|
||||
|
||||
The command palette lets you browse, search and trigger all keyboard shortcuts
|
||||
and actions in |kitty| from a single searchable overlay. Press
|
||||
:sc:`command_palette` to open it (default: :kbd:`Ctrl+Shift+F3`).
|
||||
|
||||
.. figure:: ../screenshots/command-palette.webp
|
||||
:alt: A screenshot of the command palette kitten
|
||||
:align: center
|
||||
:width: 100%
|
||||
|
||||
The command palette showing search results for ``win close``.
|
||||
|
||||
All mapped actions (those with a keyboard shortcut) and unmapped actions (those
|
||||
available but not bound to any key) are listed, organized by category. Mouse
|
||||
bindings are shown in a separate section. Simply type to search, select a
|
||||
result, and press :kbd:`Enter` to run it.
|
||||
|
||||
|
||||
Searching
|
||||
-----------
|
||||
|
||||
As you type into the search bar, the palette filters results in real time.
|
||||
Matching is case-insensitive and works across three columns simultaneously:
|
||||
the **key** (keyboard shortcut), the **action** name, and the **category**.
|
||||
Matched characters are highlighted so you can see exactly where each term hit.
|
||||
|
||||
**Multiple words**
|
||||
Separate your terms with spaces. Typing ``scroll page`` looks for items
|
||||
that contain *scroll* and *page* anywhere across the key, action, or
|
||||
category columns. Items that match more of your terms are ranked higher
|
||||
than those that match fewer.
|
||||
|
||||
**How individual words are matched**
|
||||
Each word in your query is compared against every word in the three
|
||||
columns. The best match wins and determines the item's score for that
|
||||
term:
|
||||
|
||||
- *Exact word* — the query word equals a column word exactly (highest score).
|
||||
- *Prefix* — the column word starts with the query word,
|
||||
e.g. ``scr`` matches ``scroll``.
|
||||
- *Typo tolerance* — for words of four characters or longer, a single
|
||||
typo (one character inserted, deleted, or substituted) still produces a
|
||||
match, and two typos give a lower-scoring match.
|
||||
|
||||
An item appears in the results as long as at least one query word matches
|
||||
something. Items where more query words match rank above those where fewer
|
||||
match.
|
||||
|
||||
**Compound names**
|
||||
Delimiters such as ``_``, ``+``, ``/``, and ``-`` are kept intact inside a
|
||||
query word, so you can search for compound action names as a unit.
|
||||
Typing ``mouse_selection`` first tries to find that exact substring in each
|
||||
column. If that fails, it splits the token into its parts (``mouse`` and
|
||||
``selection``) and matches each part independently against the column words.
|
||||
|
||||
**Ranking**
|
||||
When multiple items match the same query, they are sorted by:
|
||||
|
||||
1. Number of query words that matched (more is better).
|
||||
2. Score on the action column (action matches outrank key or category matches).
|
||||
3. Score on the key column.
|
||||
4. Score on the category column.
|
||||
5. Shorter action name as a tiebreaker (more specific results first).
|
||||
|
||||
|
||||
Keyboard controls
|
||||
-------------------
|
||||
|
||||
The following keys are available while the command palette is open:
|
||||
|
||||
.. list-table::
|
||||
:widths: auto
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Action
|
||||
* - Any text
|
||||
- Filter results by typing a search query
|
||||
* - :kbd:`Enter`
|
||||
- Run the selected action
|
||||
* - :kbd:`Escape`
|
||||
- Clear the search query, or close the palette if the query is already empty
|
||||
* - :kbd:`Up` / :kbd:`Ctrl+K` / :kbd:`Ctrl+P`
|
||||
- Move selection up
|
||||
* - :kbd:`Down` / :kbd:`Ctrl+J` / :kbd:`Ctrl+N`
|
||||
- Move selection down
|
||||
* - :kbd:`Page Up`
|
||||
- Move selection up by a page
|
||||
* - :kbd:`Page Down`
|
||||
- Move selection down by a page
|
||||
* - :kbd:`Home`
|
||||
- Jump to the first result
|
||||
* - :kbd:`End`
|
||||
- Jump to the last result
|
||||
* - :kbd:`Backspace`
|
||||
- Delete the last character from the query
|
||||
* - :kbd:`F12`
|
||||
- Toggle display of unmapped actions
|
||||
* - Mouse click
|
||||
- Select and run the clicked action
|
||||
|
||||
|
||||
Unmapped actions
|
||||
------------------
|
||||
|
||||
By default, the palette shows both mapped actions (those bound to a shortcut)
|
||||
and unmapped actions (those with no shortcut assigned). Unmapped actions appear
|
||||
with an ``(unmapped)`` label in the key column. Press :kbd:`F12` to toggle
|
||||
their visibility. This preference is remembered across sessions.
|
||||
|
||||
Unmapped actions are useful for discovering functionality that you may not have
|
||||
configured a shortcut for. You can run them directly from the palette, or note
|
||||
the action name and add a mapping in :file:`kitty.conf`.
|
||||
|
||||
|
||||
Pinning frequently used actions
|
||||
---------------------------------
|
||||
|
||||
When the search query is empty, actions defined with :opt:`action_alias` and
|
||||
:opt:`kitten_alias` are shown at the top of the palette, above all other
|
||||
actions. They are shown even when unmapped actions are hidden with :kbd:`F12`.
|
||||
To keep actions you use often at the top, define an alias for each of them in
|
||||
:file:`kitty.conf`, for example::
|
||||
|
||||
action_alias fav_session launch --type=background kitty --session ~/.config/kitty/last.session
|
||||
action_alias fav_detach detach_tab ask
|
||||
|
||||
|
||||
Custom keyboard modes
|
||||
-----------------------
|
||||
|
||||
If you have defined custom :ref:`keyboard modes <modal_mappings>` in your
|
||||
configuration, their bindings appear under separate mode headers in the palette.
|
||||
The ``push_keyboard_mode`` bindings are grouped with the target mode they
|
||||
activate, making it easy to see how to enter each mode alongside its shortcuts.
|
||||
|
||||
|
||||
Configuration
|
||||
--------------
|
||||
|
||||
The default mapping to open the command palette is::
|
||||
|
||||
map kitty_mod+f3 command_palette
|
||||
|
||||
You can change this in :file:`kitty.conf` like any other mapping. For example::
|
||||
|
||||
map ctrl+p command_palette
|
||||
@@ -0,0 +1,338 @@
|
||||
Custom kittens
|
||||
=================
|
||||
|
||||
You can easily create your own kittens to extend kitty. They are just terminal
|
||||
programs written in Python. When launching a kitten, kitty will open an overlay
|
||||
window over the current window and optionally pass the contents of the current
|
||||
window/scrollback to the kitten over its :file:`STDIN`. The kitten can then
|
||||
perform whatever actions it likes, just as a normal terminal program. After
|
||||
execution of the kitten is complete, it has access to the running kitty instance
|
||||
so it can perform arbitrary actions such as closing windows, pasting text, etc.
|
||||
|
||||
Let's see a simple example of creating a kitten. It will ask the user for some
|
||||
input and paste it into the terminal window.
|
||||
|
||||
Create a file in the kitty config directory, :file:`~/.config/kitty/mykitten.py`
|
||||
(you might need to adjust the path to wherever the :ref:`kitty config directory
|
||||
<confloc>` is on your machine).
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from kitty.boss import Boss
|
||||
|
||||
def main(args: list[str]) -> str:
|
||||
# this is the main entry point of the kitten, it will be executed in
|
||||
# the overlay window when the kitten is launched
|
||||
answer = input('Enter some text: ')
|
||||
# whatever this function returns will be available in the
|
||||
# handle_result() function
|
||||
return answer
|
||||
|
||||
def handle_result(args: list[str], answer: str, target_window_id: int, boss: Boss) -> None:
|
||||
# get the kitty window into which to paste answer
|
||||
w = boss.window_id_map.get(target_window_id)
|
||||
if w is not None:
|
||||
w.paste_text(answer)
|
||||
|
||||
|
||||
Now in :file:`kitty.conf` add the lines::
|
||||
|
||||
map ctrl+k kitten mykitten.py
|
||||
|
||||
|
||||
Start kitty and press :kbd:`Ctrl+K` and you should see the kitten running.
|
||||
The best way to develop your own kittens is to modify one of the built-in
|
||||
kittens. Look in the :repo_folder:`kittens sub-directory <kittens>` of the kitty source
|
||||
code for those. Or see below for a list of :ref:`third-party kittens
|
||||
<external_kittens>`, that other kitty users have created.
|
||||
|
||||
kitty API to use with kittens
|
||||
-------------------------------
|
||||
|
||||
Kittens have full access to internal kitty APIs. However these are neither
|
||||
entirely stable nor documented. You can instead use the kitty
|
||||
:doc:`Remote control API </remote-control>`. Simply call
|
||||
:code:`boss.call_remote_control()`, with the same arguments you
|
||||
would pass to ``kitten @``. For example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def handle_result(args: list[str], answer: str, target_window_id: int, boss: Boss) -> None:
|
||||
# get the kitty window to which to send text
|
||||
w = boss.window_id_map.get(target_window_id)
|
||||
if w is not None:
|
||||
boss.call_remote_control(w, ('send-text', f'--match=id:{w.id}', 'hello world'))
|
||||
|
||||
.. note::
|
||||
Inside handle_result() the active window is still the window in which the
|
||||
kitten was run, therefore when using call_remote_control() be sure to pass
|
||||
the appropriate option to select the target window, usually ``--match`` as
|
||||
shown above or ``--self``.
|
||||
|
||||
|
||||
Run, ``kitten @ --help`` in a kitty terminal, to see all the remote control
|
||||
commands available to you.
|
||||
|
||||
Passing arguments to kittens
|
||||
------------------------------
|
||||
|
||||
You can pass arguments to kittens by defining them in the map directive in
|
||||
:file:`kitty.conf`. For example::
|
||||
|
||||
map ctrl+k kitten mykitten.py arg1 arg2
|
||||
|
||||
These will be available as the ``args`` parameter in the ``main()`` and
|
||||
``handle_result()`` functions. Note also that the current working directory
|
||||
of the kitten is set to the working directory of whatever program is running in
|
||||
the active kitty window. The special argument ``@selection`` is replaced by the
|
||||
currently selected text in the active kitty window.
|
||||
|
||||
|
||||
Passing the contents of the screen to the kitten
|
||||
---------------------------------------------------
|
||||
|
||||
If you would like your kitten to have access to the contents of the screen
|
||||
and/or the scrollback buffer, you just need to add an annotation to the
|
||||
``handle_result()`` function, telling kitty what kind of input your kitten would
|
||||
like. For example:
|
||||
|
||||
.. code-block:: py
|
||||
|
||||
from kitty.boss import Boss
|
||||
|
||||
# in main, STDIN is for the kitten process and will contain
|
||||
# the contents of the screen
|
||||
def main(args: list[str]) -> str:
|
||||
return sys.stdin.read()
|
||||
|
||||
# in handle_result, STDIN is for the kitty process itself, rather
|
||||
# than the kitten process and should not be read from.
|
||||
from kittens.tui.handler import result_handler
|
||||
@result_handler(type_of_input='text')
|
||||
def handle_result(args: list[str], stdin_data: str, target_window_id: int, boss: Boss) -> None:
|
||||
pass
|
||||
|
||||
|
||||
This will send the plain text of the active window to the kitten's
|
||||
:file:`STDIN`. There are many other types of input you can ask for, described in
|
||||
the table below:
|
||||
|
||||
.. table:: Types of input to kittens
|
||||
:align: left
|
||||
|
||||
=========================== ========================================================================================
|
||||
Keyword Type of :file:`STDIN` input
|
||||
=========================== ========================================================================================
|
||||
``text`` Plain text of active window
|
||||
``ansi`` Formatted text of active window
|
||||
``screen`` Plain text of active window with line wrap markers
|
||||
``screen-ansi`` Formatted text of active window with line wrap markers
|
||||
|
||||
``history`` Plain text of active window and its scrollback
|
||||
``ansi-history`` Formatted text of active window and its scrollback
|
||||
``screen-history`` Plain text of active window and its scrollback with line wrap markers
|
||||
``screen-ansi-history`` Formatted text of active window and its scrollback with line wrap markers
|
||||
|
||||
``output`` Plain text of the output from the last run command
|
||||
``output-screen`` Plain text of the output from the last run command with wrap markers
|
||||
``output-ansi`` Formatted text of the output from the last run command
|
||||
``output-screen-ansi`` Formatted text of the output from the last run command with wrap markers
|
||||
|
||||
``selection`` The text currently selected with the mouse
|
||||
=========================== ========================================================================================
|
||||
|
||||
In addition to ``output``, that gets the output of the last run command,
|
||||
``last_visited_output`` gives the output of the command last jumped to
|
||||
and ``first_output`` gives the output of the first command currently on screen.
|
||||
These can also be combined with ``screen`` and ``ansi`` for formatting.
|
||||
|
||||
.. note::
|
||||
For the types based on the output of a command, :ref:`shell_integration` is
|
||||
required.
|
||||
|
||||
|
||||
Using kittens to script kitty, without any terminal UI
|
||||
-----------------------------------------------------------
|
||||
|
||||
If you would like your kitten to script kitty, without bothering to write a
|
||||
terminal program, you can tell the kittens system to run the ``handle_result()``
|
||||
function without first running the ``main()`` function.
|
||||
|
||||
For example, here is a kitten that "zooms in/zooms out" the current terminal
|
||||
window by switching to the stack layout or back to the previous layout. This is
|
||||
equivalent to the builtin :ac:`toggle_layout` action.
|
||||
|
||||
Create a Python file in the :ref:`kitty config directory <confloc>`,
|
||||
:file:`~/.config/kitty/zoom_toggle.py`
|
||||
|
||||
.. code-block:: py
|
||||
|
||||
from kitty.boss import Boss
|
||||
|
||||
def main(args: list[str]) -> str:
|
||||
pass
|
||||
|
||||
from kittens.tui.handler import result_handler
|
||||
@result_handler(no_ui=True)
|
||||
def handle_result(args: list[str], answer: str, target_window_id: int, boss: Boss) -> None:
|
||||
tab = boss.active_tab
|
||||
if tab is not None:
|
||||
if tab.current_layout.name == 'stack':
|
||||
tab.last_used_layout()
|
||||
else:
|
||||
tab.goto_layout('stack')
|
||||
|
||||
|
||||
Now in :file:`kitty.conf` add::
|
||||
|
||||
map f11 kitten zoom_toggle.py
|
||||
|
||||
Pressing :kbd:`F11` will now act as a zoom toggle function. You can get even
|
||||
more fancy, switching the kitty OS window to fullscreen as well as changing the
|
||||
layout, by simply adding the line::
|
||||
|
||||
boss.toggle_fullscreen()
|
||||
|
||||
|
||||
to the ``handle_result()`` function, above.
|
||||
|
||||
|
||||
.. _send_mouse_event:
|
||||
|
||||
Sending mouse events
|
||||
--------------------
|
||||
|
||||
If the program running in a window is receiving mouse events, you can simulate
|
||||
those using::
|
||||
|
||||
from kitty.fast_data_types import send_mouse_event
|
||||
send_mouse_event(screen, x, y, button, action, mods)
|
||||
|
||||
``screen`` is the ``screen`` attribute of the window you want to send the event
|
||||
to. ``x`` and ``y`` are the 0-indexed coordinates. ``button`` is a number using
|
||||
the same numbering as X11 (left: ``1``, middle: ``2``, right: ``3``, scroll up:
|
||||
``4``, scroll down: ``5``, scroll left: ``6``, scroll right: ``7``, back:
|
||||
``8``, forward: ``9``). ``action`` is one of ``PRESS``, ``RELEASE``, ``DRAG``
|
||||
or ``MOVE``. ``mods`` is a bitmask of ``GLFW_MOD_{mod}`` where ``{mod}`` is one
|
||||
of ``SHIFT``, ``CONTROL`` or ``ALT``. All the mentioned constants are imported
|
||||
from ``kitty.fast_data_types``.
|
||||
|
||||
For example, to send a left click at position x: 2, y: 3 to the active window::
|
||||
|
||||
from kitty.fast_data_types import send_mouse_event, PRESS
|
||||
send_mouse_event(boss.active_window.screen, 2, 3, 1, PRESS, 0)
|
||||
|
||||
The function will only send the event if the program is receiving events of
|
||||
that type, and will return ``True`` if it sent the event, and ``False`` if not.
|
||||
|
||||
|
||||
.. _kitten_main_rc:
|
||||
|
||||
Using remote control inside the main() kitten function
|
||||
------------------------------------------------------------
|
||||
|
||||
You can use kitty's remote control features inside the main() function of a
|
||||
kitten, even without enabling remote control. This is useful if you want to
|
||||
probe kitty for more information before presenting some UI to the user or if
|
||||
you want the user to be able to control kitty from within your kitten's UI
|
||||
rather than after it has finished running. To enable it, simply tell kitty your kitten
|
||||
requires remote control, as shown in the example below::
|
||||
|
||||
import json
|
||||
import sys
|
||||
from pprint import pprint
|
||||
|
||||
from kittens.tui.handler import kitten_ui
|
||||
|
||||
@kitten_ui(allow_remote_control=True)
|
||||
def main(args: list[str]) -> str:
|
||||
# get the result of running kitten @ ls
|
||||
cp = main.remote_control(['ls'], capture_output=True)
|
||||
if cp.returncode != 0:
|
||||
sys.stderr.buffer.write(cp.stderr)
|
||||
raise SystemExit(cp.returncode)
|
||||
output = json.loads(cp.stdout)
|
||||
pprint(output)
|
||||
# open a new tab with a title specified by the user
|
||||
title = input('Enter the name of tab: ')
|
||||
window_id = main.remote_control(['launch', '--type=tab', '--tab-title', title], check=True, capture_output=True).stdout.decode()
|
||||
return window_id
|
||||
|
||||
:code:`allow_remote_control=True` tells kitty to run this kitten with remote
|
||||
control enabled, regardless of whether it is enabled globally or not.
|
||||
To run a remote control command use the :code:`main.remote_control()` function
|
||||
which is a thin wrapper around Python's :code:`subprocess.run` function. Note
|
||||
that by default, for security, child processes launched by your kitten cannot use remote
|
||||
control, thus it is necessary to use :code:`main.remote_control()`. If you wish
|
||||
to enable child processes to use remote control, call
|
||||
:code:`main.allow_indiscriminate_remote_control()`.
|
||||
|
||||
Remote control access can be further secured by using
|
||||
:code:`kitten_ui(allow_remote_control=True, remote_control_password='ls set-colors')`.
|
||||
This will use a secure generated password to restrict remote control.
|
||||
You can specify a space separated list of remote control commands to allow, see
|
||||
:opt:`remote_control_password` for details. The password value is accessible
|
||||
as :code:`main.password` and is used by :code:`main.remote_control()`
|
||||
automatically.
|
||||
|
||||
|
||||
Debugging kittens
|
||||
--------------------
|
||||
|
||||
The part of the kitten that runs in ``main()`` is just a normal program and the
|
||||
output of print statements will be visible in the kitten window. Or alternately,
|
||||
you can use::
|
||||
|
||||
from kittens.tui.loop import debug
|
||||
debug('whatever')
|
||||
|
||||
The ``debug()`` function is just like ``print()`` except that the output will
|
||||
appear in the ``STDOUT`` of the kitty process inside which the kitten is
|
||||
running.
|
||||
|
||||
The ``handle_result()`` part of the kitten runs inside the kitty process.
|
||||
The output of print statements will go to the ``STDOUT`` of the kitty process.
|
||||
So if you run kitty from another kitty instance, the output will be visible
|
||||
in the first kitty instance.
|
||||
|
||||
|
||||
Developing builtin kittens for inclusion with kitty
|
||||
----------------------------------------------------------
|
||||
|
||||
There is documentation for :doc:`developing-builtin-kittens` which are written in the Go
|
||||
language.
|
||||
|
||||
|
||||
.. _external_kittens:
|
||||
|
||||
Kittens created by kitty users
|
||||
---------------------------------------------
|
||||
|
||||
`vim-kitty-navigator <https://github.com/knubie/vim-kitty-navigator>`_
|
||||
Allows you to navigate seamlessly between vim and kitty splits using a
|
||||
consistent set of hotkeys.
|
||||
|
||||
`smart-scroll <https://github.com/yurikhan/kitty-smart-scroll>`_
|
||||
Makes the kitty scroll bindings work in full screen applications
|
||||
|
||||
`kitty-tab-switcher <https://github.com/OsiPog/kitty-tab-switcher>`__
|
||||
Fuzzy finder for kitty tabs with previews
|
||||
|
||||
`gattino <https://github.com/salvozappa/gattino>`__
|
||||
Integrate kitty with an LLM to convert plain language prompts into shell commands.
|
||||
|
||||
:iss:`insert password <1222>`
|
||||
Insert a password from a CLI password manager, taking care to only do it at
|
||||
a password prompt.
|
||||
|
||||
`weechat-hints <https://github.com/GermainZ/kitty-weechat-hints>`_
|
||||
URL hints kitten for WeeChat that works without having to use WeeChat's
|
||||
raw-mode.
|
||||
|
||||
`pdf-kitten <https://github.com/gelaechter/pdf-kitten>`__
|
||||
Allows you to export kitty's output to PDF, making use of weasyprint.
|
||||
|
||||
`kitty-action-menu <https://github.com/olispeedy/kitty-action-menu>`__
|
||||
A pop-up action menu (copy selection, copy link/path, paste, new tab, split,
|
||||
close) opened by right-click or any mapping.
|
||||
@@ -0,0 +1,142 @@
|
||||
Using terminal programs to provide Linux desktop components
|
||||
===============================================================
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
--------------
|
||||
|
||||
.. versionadded:: 0.43.0
|
||||
|
||||
Power users of terminals on Linux also often like to use bare bones window
|
||||
managers instead of full fledged desktop environments. This kitten helps
|
||||
provide parts of the desktop environment that are missing from such setups,
|
||||
and does so using keyboard friendly, terminal first, UI components. Some of its
|
||||
features are:
|
||||
|
||||
* Replace the typical File Open/Save dialogs used in GUI programs with the
|
||||
fast and keyboard centric :doc:`choose-files </kittens/choose-files>` kitten
|
||||
running in a semi-transparent kitty overlay.
|
||||
|
||||
* Allow simple command line based management of the desktop light/dark modes.
|
||||
|
||||
|
||||
How to install
|
||||
-------------------
|
||||
|
||||
.. note::
|
||||
|
||||
This kitten relies on the :doc:`panel kitten </kittens/panel>`
|
||||
under the hood to supply UI components. Check :ref:`the documentation <panel_compat>`
|
||||
of that kitten to see if your window manager works with it.
|
||||
|
||||
First, run::
|
||||
|
||||
kitten desktop-ui enable-portal
|
||||
|
||||
Then, set the following two environment variables, *system wide*, that means in
|
||||
:file:`/etc/environment` or the equivalent for your distribution::
|
||||
|
||||
QT_QPA_PLATFORMTHEME=xdgdesktopportal
|
||||
GTK_USE_PORTAL=1
|
||||
|
||||
|
||||
Finally, reboot. Now, when you open a file dialog in most GUI applications, it
|
||||
should open the :doc:`choose-files kitten </kittens/choose-files>` instead
|
||||
of a normal file open dialog. You can change the current light/dark mode of
|
||||
your desktop by running::
|
||||
|
||||
kitten desktop-ui set-color-scheme dark
|
||||
kitten desktop-ui set-color-scheme light
|
||||
|
||||
Check the current value using::
|
||||
|
||||
dbus-send --session --print-reply --dest=org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read string:org.freedesktop.appearance string:color-scheme
|
||||
|
||||
How it works
|
||||
----------------
|
||||
|
||||
Modern Linux desktops have so called `portals
|
||||
<https://flatpak.github.io/xdg-desktop-portal/docs/index.html>`__ that were
|
||||
invented for sandboxed applications and provide various facilities to such
|
||||
applications over DBUS, including file open dialogs, common desktop settings,
|
||||
etc. This kitten works by implementing a backend for some of these services.
|
||||
|
||||
Normal GUI applications can then be told to make use of these services, thereby
|
||||
allowing us to replace parts of the desktop experience as needed.
|
||||
|
||||
There are multiple competing implementations of the backends. Each desktop
|
||||
environment like KDE or GNOME has it's own backend and many window managers
|
||||
provide implementations for some backends as well. Service discovery and
|
||||
configuring which backend to use happens via the :file:`xdg-desktop-portal`
|
||||
program, usually found at :file:`/usr/lib/xdg-desktop-portal`.
|
||||
|
||||
It can be configured by files in :file:`$XDG_CONFIG_HOME/xdg-desktop-portal`,
|
||||
which defaults to :file:`~/.config/xdg-desktop-portal`. See
|
||||
`man portals.conf <https://man.archlinux.org/man/portals.conf.5>`__. The
|
||||
``kitten desktop-ui enable-portal`` command takes care of the setup for you
|
||||
automatically. If you want to customize exactly which services to use this
|
||||
kitten for, run the command and then edit the conf file that the command says
|
||||
it has patched.
|
||||
|
||||
|
||||
Troubleshooting
|
||||
-------------------
|
||||
|
||||
First, ensure that DBUS is able to auto-start the kitten when it is needed. If
|
||||
the kitten is not already running, try the following command::
|
||||
|
||||
dbus-send --session --print-reply --dest=org.freedesktop.impl.portal.desktop.kitty \
|
||||
/net/kovidgoyal/kitty/portal org.freedesktop.DBus.Properties.GetAll \
|
||||
string:net.kovidgoyal.kitty.settings
|
||||
|
||||
If DBUS is able to start the kitten or if it is already running it will print
|
||||
out the version property, otherwise it will fail with an error. If it fails,
|
||||
check the file
|
||||
:file:`~/.local/share/dbus-1/services/org.freedesktop.impl.portal.desktop.kitty.service`
|
||||
that should have been created by the ``enable-portal`` command. It's ``Exec``
|
||||
key must point to the full path to the kitten executable.
|
||||
|
||||
Next, check that the XDG portal system is actually using this kitten for its
|
||||
settings backend. Run::
|
||||
|
||||
dbus-send --session --print-reply --dest=org.freedesktop.portal.Desktop \
|
||||
/org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read \
|
||||
string:net.kovidgoyal.kitty string:status
|
||||
|
||||
If this returns a reply then the kitten is being used, as expected. If it
|
||||
returns a not found error, then some other backend is being used for settings.
|
||||
|
||||
Read the ``portals.conf`` man page and run::
|
||||
|
||||
/usr/lib/xdg-desktop-portal -r -v
|
||||
|
||||
this will output a lot of debug information, which should tell you which
|
||||
backend is chosen for which service. Read the debug output carefully to
|
||||
determine why the kitten is not being selected.
|
||||
|
||||
If some GUI applications are not using the choose-files kitten for their file
|
||||
select dialogs, then make sure the environment variables mentioned above are
|
||||
set, you can also try running the GUI application with them set explicitly,
|
||||
as::
|
||||
|
||||
QT_QPA_PLATFORMTHEME=xdgdesktopportal GTK_USE_PORTAL=1 my-gui-app
|
||||
|
||||
Note that not all applications use portals, so if some particular application
|
||||
is failing to use the portal but others work, report the issue to that
|
||||
applications' developers.
|
||||
|
||||
.. note::
|
||||
|
||||
File chooser integration requires your window manager to support
|
||||
:ref:`panels <panel_compat>` so check the compatibility table.
|
||||
|
||||
Configuration
|
||||
------------------------
|
||||
|
||||
You can configure various aspects of the kitten's operation by creating a
|
||||
:file:`desktop-ui-portal.conf` in your :ref:`kitty config folder <confloc>`.
|
||||
See below for the supported configuration directives.
|
||||
|
||||
|
||||
.. include:: /generated/conf-kitten-desktop_ui.rst
|
||||
@@ -0,0 +1,119 @@
|
||||
Developing builtin kittens
|
||||
=============================
|
||||
|
||||
Builtin kittens in kitty are written in the Go language, with small Python
|
||||
wrapper scripts to define command line options and handle UI integration.
|
||||
|
||||
Getting started
|
||||
-----------------------
|
||||
|
||||
To get started with creating a builtin kitten, one that will become part of kitty
|
||||
and be available as ``kitten my-kitten``, create a directory named
|
||||
:file:`my_kitten` in the :file:`kittens` directory. Then, in this directory
|
||||
add three files: :file:`__init__.py` (an empty file), :file:`main.py` and
|
||||
:file:`main.go`.
|
||||
|
||||
Template for `main.py`
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The file :file:`main.py` contains the command line option definitions for your kitten. Change the actual options and help text below as needed.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
#!/usr/bin/env python
|
||||
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import sys
|
||||
|
||||
# See the file kitty/cli.py in the kitty sourcecode for more examples of
|
||||
# the syntax for defining options
|
||||
OPTIONS = r'''
|
||||
--some-string-option -s
|
||||
default=my_default_value
|
||||
Help text for a simple option taking a string value.
|
||||
|
||||
|
||||
--some-boolean-option -b
|
||||
type=bool-set
|
||||
Help text for a boolean option defaulting to false.
|
||||
|
||||
|
||||
--some-inverted-boolean-option
|
||||
type=bool-unset
|
||||
Help text for a boolean option defaulting to true.
|
||||
|
||||
|
||||
--an-integer-option
|
||||
type=int
|
||||
default=13
|
||||
bla bla
|
||||
|
||||
|
||||
--an-enum-option
|
||||
choices=a,b,c,d
|
||||
default=a
|
||||
This option can only take the values a, b, c, or d
|
||||
'''.format
|
||||
|
||||
help_text = '''\
|
||||
The introductory help text for your kitten.
|
||||
|
||||
Can contain multiple paragraphs with :bold:`bold`
|
||||
:green:`colored`, :code:`code`, :link:`links <http://url>` etc.
|
||||
formatting.
|
||||
|
||||
Option help strings can also use this formatting.
|
||||
'''
|
||||
|
||||
# The usage string for your kitten
|
||||
usage = 'TITLE [BODY ...]'
|
||||
short_description = 'A short description of your kitten'
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit('This should be run as kitten my-kitten')
|
||||
elif __name__ == '__doc__':
|
||||
cd = sys.cli_docs # type: ignore
|
||||
cd['usage'] = usage
|
||||
cd['options'] = OPTIONS
|
||||
cd['help_text'] = help_text
|
||||
cd['short_desc'] = short_description
|
||||
|
||||
|
||||
Template for `main.go`
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: go
|
||||
|
||||
package my_kitten
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/kovidgoyal/kitty/tools/cli"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
func main(_ *cli.Command, opts *Options, args []string) (rc int, err error) {
|
||||
// Here rc is the exit code for the kitten which should be 1 or higher if err is not nil
|
||||
fmt.Println("Hello world!")
|
||||
fmt.Println(args)
|
||||
fmt.Println(fmt.Sprintf("%#v", opts))
|
||||
return
|
||||
}
|
||||
|
||||
func EntryPoint(parent *cli.Command) {
|
||||
create_cmd(parent, main)
|
||||
}
|
||||
|
||||
Edit :file:`tools/cmd/tool/main.go`
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Add the entry point of the kitten into :file:`tools/cmd/tool/main.go`.
|
||||
|
||||
First, import the kitten into this file. To do this, add :code:`"github.com/kovidgoyal/kitty/kittens/my_kitten"` into the :code:`import ( ... )` section at the top.
|
||||
Then, add ``my_kitten.EntryPoint(root)`` into ``func KittyToolEntryPoints(root *cli.Command)`` and you are done. After running make you should
|
||||
be able to test your kitten by running::
|
||||
|
||||
kitten my-kitten
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
kitty-diff
|
||||
================================================================================
|
||||
|
||||
*A fast side-by-side diff tool with syntax highlighting and images*
|
||||
|
||||
.. highlight:: sh
|
||||
|
||||
Major Features
|
||||
-----------------
|
||||
|
||||
.. container:: major-features
|
||||
|
||||
* Displays diffs side-by-side in the kitty terminal
|
||||
|
||||
* Does syntax highlighting of the displayed diffs, asynchronously, for
|
||||
maximum speed
|
||||
|
||||
* Displays images as well as text diffs, even over SSH
|
||||
|
||||
* Does recursive directory diffing
|
||||
|
||||
|
||||
.. figure:: ../screenshots/diff.png
|
||||
:alt: Screenshot, showing a sample diff
|
||||
:align: center
|
||||
:width: 100%
|
||||
|
||||
Screenshot, showing a sample diff
|
||||
|
||||
|
||||
Installation
|
||||
---------------
|
||||
|
||||
Simply :ref:`install kitty <quickstart>`.
|
||||
|
||||
|
||||
Usage
|
||||
--------
|
||||
|
||||
In the kitty terminal, run::
|
||||
|
||||
kitten diff file1 file2
|
||||
|
||||
to see the diff between :file:`file1` and :file:`file2`.
|
||||
|
||||
Create an alias in your shell's startup file to shorten the command, for
|
||||
example:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
alias d="kitten diff"
|
||||
|
||||
Now all you need to do to diff two files is::
|
||||
|
||||
d file1 file2
|
||||
|
||||
You can also pass directories instead of files to see the recursive diff of the
|
||||
directory contents.
|
||||
|
||||
|
||||
Keyboard controls
|
||||
----------------------
|
||||
|
||||
=========================== ===========================
|
||||
Action Shortcut
|
||||
=========================== ===========================
|
||||
Quit :kbd:`Q`
|
||||
Scroll line up :kbd:`K`, :kbd:`Up`
|
||||
Scroll line down :kbd:`J`, :kbd:`Down`
|
||||
Scroll page up :kbd:`PgUp`
|
||||
Scroll page down :kbd:`PgDn`
|
||||
Scroll to top :kbd:`Home`
|
||||
Scroll to bottom :kbd:`End`
|
||||
Scroll to next page :kbd:`Space`, :kbd:`PgDn`, :kbd:`Ctrl+F`
|
||||
Scroll to previous page :kbd:`PgUp`, :kbd:`Ctrl+B`
|
||||
Scroll down half page :kbd:`Ctrl+D`
|
||||
Scroll up half page :kbd:`Ctrl+U`
|
||||
Scroll to next change :kbd:`N`
|
||||
Scroll to previous change :kbd:`P`
|
||||
Increase lines of context :kbd:`+`
|
||||
Decrease lines of context :kbd:`-`
|
||||
All lines of context :kbd:`A`
|
||||
Restore default context :kbd:`=`
|
||||
Search forwards :kbd:`/`
|
||||
Search backwards :kbd:`?`
|
||||
Clear search or exit :kbd:`Esc`
|
||||
Scroll to next match :kbd:`>`, :kbd:`.`
|
||||
Scroll to previous match :kbd:`<`, :kbd:`,`
|
||||
Copy selection to clipboard :kbd:`y`
|
||||
Copy selection or exit :kbd:`Ctrl+C`
|
||||
=========================== ===========================
|
||||
|
||||
|
||||
Integrating with git
|
||||
-----------------------
|
||||
|
||||
Add the following to :file:`~/.gitconfig`:
|
||||
|
||||
.. code-block:: ini
|
||||
|
||||
[diff]
|
||||
tool = kitty
|
||||
guitool = kitty.gui
|
||||
[difftool]
|
||||
prompt = false
|
||||
trustExitCode = true
|
||||
[difftool "kitty"]
|
||||
cmd = kitten diff $LOCAL $REMOTE
|
||||
[difftool "kitty.gui"]
|
||||
cmd = kitten diff $LOCAL $REMOTE
|
||||
|
||||
Now to use kitty-diff to view git diffs, you can simply do::
|
||||
|
||||
git difftool --no-symlinks --dir-diff
|
||||
|
||||
Once again, creating an alias for this command is useful.
|
||||
|
||||
Alternatively, `git-kitten-diff <https://github.com/eureka-cpu/kitty-diff-git>`__
|
||||
is a git plugin that forwards ``git diff`` arguments to kitty-diff without
|
||||
needing any :file:`~/.gitconfig` changes. Once installed, simply run::
|
||||
|
||||
git kitten diff
|
||||
|
||||
|
||||
Why does this work only in kitty?
|
||||
----------------------------------------
|
||||
|
||||
The diff kitten makes use of various features that are :doc:`kitty only
|
||||
</protocol-extensions>`, such as the :doc:`kitty graphics protocol
|
||||
</graphics-protocol>`, the :doc:`extended keyboard protocol
|
||||
</keyboard-protocol>`, etc. It also leverages terminal program infrastructure
|
||||
I created for all of kitty's other kittens to reduce the amount of code needed
|
||||
(the entire implementation is under 3000 lines of code).
|
||||
|
||||
And fundamentally, it's kitty only because I wrote it for myself, and I am
|
||||
highly unlikely to use any other terminals :)
|
||||
|
||||
|
||||
Configuration
|
||||
------------------------
|
||||
|
||||
You can configure the colors used, keyboard shortcuts, the diff implementation,
|
||||
the default lines of context, etc. by creating a :file:`diff.conf` file in your
|
||||
:ref:`kitty config folder <confloc>`. See below for the supported configuration
|
||||
directives.
|
||||
|
||||
|
||||
.. include:: /generated/conf-kitten-diff.rst
|
||||
|
||||
|
||||
.. include:: /generated/cli-kitten-diff.rst
|
||||
|
||||
|
||||
Sample diff.conf
|
||||
-----------------
|
||||
|
||||
You can download a sample :file:`diff.conf` file with all default settings and
|
||||
comments describing each setting by clicking: :download:`sample diff.conf
|
||||
</generated/conf/diff.conf>`.
|
||||
@@ -0,0 +1,53 @@
|
||||
Drag and Drop
|
||||
==================================================
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
--------------
|
||||
|
||||
*Drag and drop of files from the shell*
|
||||
|
||||
.. highlight:: sh
|
||||
|
||||
|
||||
The ``dnd`` kitten can be used to drag and drop files between
|
||||
the shell and arbitrary GUI programs, it even works over SSH, so you
|
||||
can easily and seamlessly transfer files from one computer to another,
|
||||
simply by dragging from one kitty window to another.
|
||||
Using it is as simple as::
|
||||
|
||||
kitten dnd file-to-drag.xyz
|
||||
|
||||
Then, start dragging with the mouse inside the window, and :file:`file-to-drag.xyz`
|
||||
will be dragged and you can drop it onto a GUI file manager or another window
|
||||
running this kitten. You can specify directories as well to drag entire trees.
|
||||
|
||||
Similarly, dropping works by running the kitten::
|
||||
|
||||
kitten dnd
|
||||
|
||||
Then, drag some files from a GUI file manager or another window running the dnd kitten
|
||||
and drop them onto this window. The files will be copied or moved (depending on
|
||||
which area you drop them) into the current working directory.
|
||||
|
||||
The best part is this works even over SSH. So if you just want to quickly
|
||||
transfer some files from one computer to another all you need to so is ssh into
|
||||
the remote computer::
|
||||
|
||||
kitten ssh remote-computer-name
|
||||
|
||||
Then, run the dnd kitten on the remote computer::
|
||||
|
||||
kitten dnd files-or-dirs-to-drag
|
||||
|
||||
That's it, you can now drag form or drop to the remote computer. See below for
|
||||
customising the behavior of the kitten via command line flags.
|
||||
|
||||
This kitten uses a new protocol developed by kitty to function, for details,
|
||||
see :doc:`/dnd-protocol`.
|
||||
|
||||
.. program:: kitty +kitten dnd
|
||||
|
||||
|
||||
.. include:: /generated/cli-kitten-dnd.rst
|
||||
@@ -0,0 +1,122 @@
|
||||
Hints
|
||||
==========
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
--------------
|
||||
|
||||
|
||||
|kitty| has a *hints mode* to select and act on arbitrary text snippets
|
||||
currently visible on the screen. For example, you can press :sc:`open_url`
|
||||
to choose any URL visible on the screen and then open it using your default web
|
||||
browser.
|
||||
|
||||
.. figure:: ../screenshots/hints_mode.png
|
||||
:alt: URL hints mode
|
||||
:align: center
|
||||
:width: 100%
|
||||
|
||||
URL hints mode
|
||||
|
||||
Similarly, you can press :sc:`insert_selected_path` to select anything that
|
||||
looks like a path or filename and then insert it into the terminal, very useful
|
||||
for picking files from the output of a :program:`git` or :program:`ls` command
|
||||
and adding them to the command line for the next command.
|
||||
|
||||
You can also press :sc:`goto_file_line` to select anything that looks like a
|
||||
path or filename followed by a colon and a line number and open the file in
|
||||
your default editor at the specified line number (opening at line number will
|
||||
work only if your editor supports the +linenum command line syntax or is a
|
||||
"known" editor). The patterns and editor to be used can be modified using
|
||||
options passed to the kitten. For example::
|
||||
|
||||
map ctrl+g kitten hints --type=linenum --linenum-action=tab nvim +{line} {path}
|
||||
|
||||
will open the selected file in a new tab inside `Neovim <https://neovim.io/>`__
|
||||
when you press :kbd:`Ctrl+G`.
|
||||
|
||||
Pressing :sc:`open_selected_hyperlink` will open :term:`hyperlinks`, i.e. a URL
|
||||
that has been marked as such by the program running in the terminal,
|
||||
for example, by ``ls --hyperlink=auto``. If :program:`ls` comes with your OS
|
||||
does not support hyperlink, you may need to install `GNU Coreutils
|
||||
<https://www.gnu.org/software/coreutils/>`__.
|
||||
|
||||
You can also :doc:`customize what actions are taken for different types of URLs
|
||||
<../open_actions>`.
|
||||
|
||||
.. note:: If there are more hints than letters, hints will use multiple
|
||||
letters. In this case, when you press the first letter, only hints
|
||||
starting with that letter are displayed. Pressing the second letter will
|
||||
select that hint or press :kbd:`Enter` or :kbd:`Space` to select the empty
|
||||
hint.
|
||||
|
||||
For mouse lovers, the hints kitten also allows you to click on any matched text to
|
||||
select it instead of typing the hint character.
|
||||
|
||||
The hints kitten is very powerful to see more detailed help on its various
|
||||
options and modes of operation, see below. You can use these options to
|
||||
create mappings in :file:`kitty.conf` to select various different text
|
||||
snippets. See :sc:`insert_selected_path <insert_selected_path>` for examples.
|
||||
|
||||
|
||||
Completely customizing the matching and actions of the kitten
|
||||
---------------------------------------------------------------
|
||||
|
||||
The hints kitten supports writing simple Python scripts that can be used to
|
||||
completely customize how it finds matches and what happens when a match is
|
||||
selected. This allows the hints kitten to provide the user interface, while you
|
||||
can provide the logic for finding matches and performing actions on them. This
|
||||
is best illustrated with an example. Create the file :file:`custom-hints.py` in
|
||||
the :ref:`kitty config directory <confloc>` with the following contents:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import re
|
||||
|
||||
def mark(text, args, Mark, extra_cli_args, *a):
|
||||
# This function is responsible for finding all
|
||||
# matching text. extra_cli_args are any extra arguments
|
||||
# passed on the command line when invoking the kitten.
|
||||
# We mark all individual word for potential selection
|
||||
for idx, m in enumerate(re.finditer(r'\w+', text)):
|
||||
start, end = m.span()
|
||||
mark_text = text[start:end].replace('\n', '').replace('\0', '')
|
||||
# The empty dictionary below will be available as groupdicts
|
||||
# in handle_result() and can contain string keys and arbitrary JSON
|
||||
# serializable values.
|
||||
yield Mark(idx, start, end, mark_text, {})
|
||||
|
||||
|
||||
def handle_result(args, data, target_window_id, boss, extra_cli_args, *a):
|
||||
# This function is responsible for performing some
|
||||
# action on the selected text.
|
||||
# matches is a list of the selected entries and groupdicts contains
|
||||
# the arbitrary data associated with each entry in mark() above
|
||||
matches, groupdicts = [], []
|
||||
for m, g in zip(data['match'], data['groupdicts']):
|
||||
if m:
|
||||
matches.append(m), groupdicts.append(g)
|
||||
for word, match_data in zip(matches, groupdicts):
|
||||
# Lookup the word in a dictionary, the open_url function
|
||||
# will open the provided url in the system browser
|
||||
boss.open_url(f'https://www.google.com/search?q=define:{word}')
|
||||
|
||||
Now run kitty with::
|
||||
|
||||
kitty -o 'map f1 kitten hints --customize-processing custom-hints.py'
|
||||
|
||||
When you press the :kbd:`F1` key you will be able to select a word to
|
||||
look it up in the Google dictionary.
|
||||
|
||||
.. include:: ../generated/cli-kitten-hints.rst
|
||||
|
||||
.. note::
|
||||
|
||||
To avoid having to specify the same command line options on every
|
||||
invocation, you can use the :opt:`action_alias` option in
|
||||
:file:`kitty.conf`, creating aliases that have common sets of options.
|
||||
For example::
|
||||
|
||||
action_alias myhints kitten hints --alphabet qfjdkslaureitywovmcxzpq1234567890
|
||||
map f1 myhints --customize-processing custom-hints.py
|
||||
@@ -0,0 +1,83 @@
|
||||
Hyperlinked grep
|
||||
=================
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
--------------
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
As of ripgrep versions newer than 13.0 it supports hyperlinks
|
||||
natively so you can just add the following alias in your shell rc file:
|
||||
``alias rg="rg --hyperlink-format=kitty"`` no need to use this kitten.
|
||||
But, see below for instructions on how to customize kitty to have it open
|
||||
the hyperlinks from ripgrep in your favorite editor.
|
||||
|
||||
This kitten allows you to search your files using `ripgrep
|
||||
<https://github.com/BurntSushi/ripgrep>`__ and open the results directly in your
|
||||
favorite editor in the terminal, at the line containing the search result,
|
||||
simply by clicking on the result you want.
|
||||
|
||||
.. versionadded:: 0.19.0
|
||||
|
||||
To set it up, first create :file:`~/.config/kitty/open-actions.conf` with the
|
||||
following contents:
|
||||
|
||||
.. code:: conf
|
||||
|
||||
# Open any file with a fragment in vim, fragments are generated
|
||||
# by ripgrep or the hyperlinked-grep kitten.
|
||||
protocol file
|
||||
fragment_matches [0-9]+
|
||||
action launch --type=overlay --cwd=current vim +${FRAGMENT} -- ${FILE_PATH}
|
||||
|
||||
# Open text files without fragments in the editor
|
||||
protocol file
|
||||
mime text/*
|
||||
action launch --type=overlay --cwd=current -- ${EDITOR} -- ${FILE_PATH}
|
||||
|
||||
Now, run a search with::
|
||||
|
||||
kitten hyperlinked-grep something
|
||||
|
||||
Hold down the :kbd:`Ctrl+Shift` keys and click on any of the result lines, to
|
||||
open the file in :program:`vim` at the matching line. If you use some editor
|
||||
other than :program:`vim`, you should adjust the :file:`open-actions.conf` file
|
||||
accordingly. To open links with the keyboard instead, use
|
||||
:sc:`open_selected_hyperlink`.
|
||||
|
||||
Finally, add an alias to your shell's rc files to invoke the kitten as
|
||||
:command:`hg`::
|
||||
|
||||
alias hg="kitten hyperlinked-grep"
|
||||
|
||||
|
||||
You can now run searches with::
|
||||
|
||||
hg some-search-term
|
||||
|
||||
To learn more about kitty's powerful framework for customizing URL click
|
||||
actions, see :doc:`here </open_actions>`.
|
||||
|
||||
By default, this kitten adds hyperlinks for several parts of ripgrep output:
|
||||
the per-file header, match context lines, and match lines. You can control
|
||||
which items are linked with a :code:`--kitten hyperlink` flag. For example,
|
||||
:code:`--kitten hyperlink=matching_lines` will only add hyperlinks to the
|
||||
match lines. :code:`--kitten hyperlink=file_headers,context_lines` will link
|
||||
file headers and context lines but not match lines. :code:`--kitten
|
||||
hyperlink=none` will cause the command line to be passed directly to
|
||||
:command:`rg` so no hyperlinking will be performed. :code:`--kitten hyperlink`
|
||||
may be specified multiple times.
|
||||
|
||||
.. note::
|
||||
While you can pass any of ripgrep's command line options to the kitten and
|
||||
they will be forwarded to :program:`rg`, do not use options that change the
|
||||
output formatting as the kitten works by parsing the output from ripgrep.
|
||||
The unsupported options are: :code:`--context-separator`,
|
||||
:code:`--field-context-separator`, :code:`--field-match-separator`,
|
||||
:code:`--json`, :code:`-I --no-filename`, :code:`-0 --null`,
|
||||
:code:`--null-data`, :code:`--path-separator`. If you specify options via
|
||||
configuration file, then any changes to the default output format will not be
|
||||
supported, not just the ones listed.
|
||||
@@ -0,0 +1,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
|
||||
@@ -0,0 +1,43 @@
|
||||
notify
|
||||
==================================================
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
--------------
|
||||
|
||||
Show pop-up system notifications.
|
||||
|
||||
.. highlight:: sh
|
||||
|
||||
.. versionadded:: 0.36.0
|
||||
The notify kitten
|
||||
|
||||
The ``notify`` kitten can be used to show pop-up system notifications
|
||||
from the shell. It even works over SSH. Using it is as simple as::
|
||||
|
||||
kitten notify "Good morning" Hello world, it is a nice day!
|
||||
|
||||
To add an icon, use::
|
||||
|
||||
kitten notify --icon-path /path/to/some/image.png "Good morning" Hello world, it is a nice day!
|
||||
kitten notify --icon firefox "Good morning" Hello world, it is a nice day!
|
||||
|
||||
|
||||
To be informed when the notification is activated::
|
||||
|
||||
kitten notify --wait-for-completion "Good morning" Hello world, it is a nice day!
|
||||
|
||||
Then, the kitten will wait till the notification is either closed or activated.
|
||||
If activated, a ``0`` is printed to :file:`STDOUT`. You can press the
|
||||
:kbd:`Esc` or :kbd:`Ctrl+c` keys to abort, closing the notification.
|
||||
|
||||
To add buttons to the notification::
|
||||
|
||||
kitten notify --wait-for-completion --button One --button Two "Good morning" Hello world, it is a nice day!
|
||||
|
||||
.. program:: kitty +kitten notify
|
||||
|
||||
.. tip:: Learn about the underlying :doc:`/desktop-notifications` escape code protocol.
|
||||
|
||||
.. include:: /generated/cli-kitten-notify.rst
|
||||
@@ -0,0 +1,229 @@
|
||||
Draw a GPU accelerated dock panel on your desktop
|
||||
====================================================================================================
|
||||
|
||||
.. highlight:: sh
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
--------------
|
||||
|
||||
.. include:: ../quake-screenshots.rst
|
||||
|
||||
Draw the desktop wallpaper or docks and panels using arbitrary
|
||||
terminal programs, For example, have `btop
|
||||
<https://github.com/aristocratos/btop>`__ or `cava
|
||||
<https://github.com/karlstav/cava/>`__ be your desktop wallpaper.
|
||||
|
||||
It is useful for showing status information or notifications on your desktop
|
||||
using terminal programs instead of GUI toolkits.
|
||||
|
||||
|
||||
The screenshot to the side shows some uses of the panel kitten to draw various
|
||||
desktop components such as the background, a quick access floating terminal and
|
||||
a dock panel showing system information (Linux only).
|
||||
|
||||
.. versionadded:: 0.42.0
|
||||
|
||||
Support for macOS, see :ref:`compatibility matrix <panel_compat>` for details.
|
||||
and X11 (background and overlay).
|
||||
|
||||
.. versionadded:: 0.34.0
|
||||
|
||||
Support for Wayland. See :ref:`below <panel_compat>` for which
|
||||
Wayland compositors work.
|
||||
|
||||
Using this kitten is simple, for example::
|
||||
|
||||
kitten panel sh -c 'printf "\n\n\nHello, world."; sleep 5s'
|
||||
|
||||
This will show ``Hello, world.`` at the top edge of your screen for five
|
||||
seconds. Here, the terminal program we are running is :program:`sh` with a script
|
||||
to print out ``Hello, world!``. You can make the terminal program as complex as
|
||||
you like, as demonstrated in the screenshots.
|
||||
|
||||
If you are on Wayland or macOS, you can, for instance, run::
|
||||
|
||||
kitten panel --edge=background htop
|
||||
|
||||
to display ``htop`` as your desktop background. Remember this works in everything
|
||||
but GNOME and also, in sway, you have to disable the background wallpaper as
|
||||
sway renders that over the panel kitten surface.
|
||||
|
||||
There are projects that make use of this facility to implement generalised
|
||||
panels and desktop components:
|
||||
|
||||
.. _panel_projects:
|
||||
|
||||
* `kitty panel <https://github.com/5hubham5ingh/kitty-panel>`__
|
||||
* `pawbar <https://github.com/codelif/pawbar>`__
|
||||
|
||||
|
||||
.. _remote_control_panel:
|
||||
|
||||
Controlling panels via remote control
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
You can control panels via the kitty :doc:`remote control </remote-control>` facility. Create a panel
|
||||
with remote control enabled::
|
||||
|
||||
kitten panel -o allow_remote_control=socket-only --lines=2 \
|
||||
--listen-on=unix:/tmp/panel kitten run-shell
|
||||
|
||||
|
||||
Now you can control this panel using remote control, for example to show/hide
|
||||
it, use::
|
||||
|
||||
kitten @ --to=unix:/tmp/panel resize-os-window --action=toggle-visibility
|
||||
|
||||
To move the panel to the bottom of the screen and increase its height::
|
||||
|
||||
kitten @ --to=unix:/tmp/panel resize-os-window --action=os-panel \
|
||||
--incremental edge=bottom lines=4
|
||||
|
||||
To create a new panel running the program top, in the same instance
|
||||
(like creating a new OS window)::
|
||||
|
||||
kitten @ --to=unix:/tmp/panel launch --type=os-panel --os-panel edge=top \
|
||||
--os-panel lines=8 top
|
||||
|
||||
|
||||
.. include:: ../generated/cli-kitten-panel.rst
|
||||
|
||||
|
||||
.. _quake_ss:
|
||||
|
||||
How the screenshots were generated
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The system statistics in the background were created using::
|
||||
|
||||
kitten panel --edge=background -o background_opacity=0.2 -o background=black btop
|
||||
|
||||
This creates a kitty background window and inside it runs the `btop
|
||||
<https://github.com/aristocratos/btop>`__ program to display the statistics.
|
||||
|
||||
The floating quick access window was created by running::
|
||||
|
||||
kitten quick-access-terminal kitten run-shell \
|
||||
zsh -c 'printf "\e]66;s=4;Quick access kitty in Hyprland\a\n\n\n\nAlso uses kitty to draw desktop background\n"'
|
||||
|
||||
This starts the quick access window and inside it runs ``kitten run-shell``, which
|
||||
in turn first runs ``zsh`` to print out the message and then starts the users login
|
||||
shell.
|
||||
|
||||
The Linux dock panel was::
|
||||
|
||||
wm bar
|
||||
|
||||
This is a custom program I wrote for my personal use. It uses kitty's kitten
|
||||
infrastructure to implement the bar in a `few hundred lines of code
|
||||
<https://github.com/kovidgoyal/wm/blob/master/bar/main.go>`__.
|
||||
This was designed for my personal use only, but, there are :ref:`public projects implementing
|
||||
general purpose panels using kitty <panel_projects>`.
|
||||
|
||||
|
||||
.. _panel_compat:
|
||||
|
||||
Compatibility with various platforms
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. only:: man
|
||||
|
||||
See the HTML documentation for the compatibility matrix.
|
||||
|
||||
.. only:: not man
|
||||
|
||||
Generated with the help of the :file:`panels.py` test script.
|
||||
|
||||
.. tab-set::
|
||||
|
||||
.. tab-item:: Wayland
|
||||
|
||||
Below is a list of the status of various Wayland compositors. The panel kitten
|
||||
relies on the `wlr layer shell protocol
|
||||
<https://wayland.app/protocols/wlr-layer-shell-unstable-v1#compositor-support>`__,
|
||||
which is technically supported by almost all Wayland compositors, but the
|
||||
implementation in some of them is quite buggy.
|
||||
|
||||
🟢 **Hyprland**
|
||||
Fully working, no known issues
|
||||
|
||||
🟢 **labwc**
|
||||
Fully working, no known issues
|
||||
|
||||
🟢 **niri**
|
||||
Fully working, no known issues
|
||||
|
||||
🟢 **river**
|
||||
Fully working, no known issues
|
||||
|
||||
🟢 **Xfce**
|
||||
Fully working, no known issues
|
||||
|
||||
🟠 **KDE** (kwin)
|
||||
Mostly working, except that clicks outside background panels cause kwin to :iss:`erroneously hide the panel <8715>`. KDE uses an `undocumented mapping <https://invent.kde.org/plasma/kwin/-/blob/3dc5cee6b34792486b343098e55e7f2b90dfcd00/src/layershellv1window.cpp#L24>`__ under Wayland to set the window type from the :code:`kitten panel --app-id` flag. You might want to use :code:`--app-id=dock` so that KDE treats the window as a dock panel, and disables window appearing/disappearing animations for it.
|
||||
|
||||
🟠 **Sway**
|
||||
Renders its configured background over the background window instead of
|
||||
under it. This is because it uses the wlr protocol for backgrounds itself.
|
||||
|
||||
🔴 **GNOME** (mutter)
|
||||
Does not implement the wlr protocol at all, nothing works.
|
||||
|
||||
.. tab-item:: macOS
|
||||
|
||||
Mostly everything works, with the notable exception that dock panels do not
|
||||
prevent other windows from covering them. This is because Apple does not
|
||||
provide and way to do this in their APIs.
|
||||
|
||||
.. tab-item:: X11
|
||||
|
||||
Support is highly dependent on the quirks of individual window
|
||||
managers. See the matrix below:
|
||||
|
||||
.. list-table:: Compatibility matrix
|
||||
:header-rows: 1
|
||||
:stub-columns: 1
|
||||
|
||||
* - WM
|
||||
- Desktop
|
||||
- Dock
|
||||
- Quick
|
||||
- Notes
|
||||
|
||||
* - KDE
|
||||
- 🟠
|
||||
- 🟢
|
||||
- 🟢
|
||||
- transparency does not work for :option:`--edge=background <--edge>`
|
||||
|
||||
* - GNOME
|
||||
- 🟢
|
||||
- 🟢
|
||||
- 🟢
|
||||
-
|
||||
|
||||
* - XFCE
|
||||
- 🟢
|
||||
- 🟢
|
||||
- 🟢
|
||||
-
|
||||
|
||||
* - i3
|
||||
- 🔴
|
||||
- 🟠
|
||||
- 🔴
|
||||
- only top and bottom dock panels, without transparency
|
||||
|
||||
* - xmonad
|
||||
- 🔴
|
||||
- 🔴
|
||||
- 🔴
|
||||
- doesn't support the needed NET_WM protocols
|
||||
|
||||
* - bspwm
|
||||
- 🔴
|
||||
- 🔴
|
||||
- 🔴
|
||||
- doesn't support the needed NET_WM protocols
|
||||
@@ -0,0 +1,25 @@
|
||||
Query terminal
|
||||
=================
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
--------------
|
||||
|
||||
|
||||
This kitten is used to query |kitty| from terminal programs about version, values
|
||||
of various runtime options controlling its features, etc.
|
||||
|
||||
The querying is done using the (*semi*) standard XTGETTCAP escape sequence
|
||||
pioneered by xterm, so it works over SSH as well. The downside is that it is
|
||||
slow, since it requires a roundtrip to the terminal emulator and back.
|
||||
|
||||
If you want to do some of the same querying in your terminal program without
|
||||
depending on the kitten, you can do so, by processing the same escape codes.
|
||||
Search `this page <https://invisible-island.net/xterm/ctlseqs/ctlseqs.html>`__
|
||||
for *XTGETTCAP* to see the syntax for the escape code. The kitty specific keys
|
||||
are all documented below, when sent via escape code they must be prefixed with
|
||||
``kitty-query-``.
|
||||
|
||||
|
||||
.. include:: ../generated/cli-kitten-query_terminal.rst
|
||||
@@ -0,0 +1,97 @@
|
||||
.. _quake:
|
||||
|
||||
Make a Quake like quick access terminal
|
||||
====================================================================================================
|
||||
|
||||
.. highlight:: sh
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
--------------
|
||||
|
||||
|
||||
.. include:: ../quake-screenshots.rst
|
||||
|
||||
.. versionadded:: 0.42.0
|
||||
See :ref:`here for what platforms it works on <panel_compat>`.
|
||||
|
||||
This kitten can be used to make a quick access terminal, that appears and
|
||||
disappears at a key press. To do so use the following command:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
kitten quick-access-terminal
|
||||
|
||||
Run this command in a terminal, and a quick access kitty window will show up at
|
||||
the top of your screen. Run it again, and the window will be hidden.
|
||||
|
||||
To make the terminal appear and disappear at a key press:
|
||||
|
||||
.. |macOs| replace:: :guilabel:`System Preferences->Keyboard->Keyboard Shortcuts->Services->General`
|
||||
|
||||
.. only:: not man
|
||||
|
||||
.. tab-set::
|
||||
|
||||
.. tab-item:: Linux
|
||||
|
||||
Simply bind the above command to some key press in your window manager or desktop
|
||||
environment settings and then you have a quick access terminal at a single key press.
|
||||
|
||||
.. tab-item:: macOS
|
||||
|
||||
In kitty, run the above command to show the quick access window, then close
|
||||
it by running the command again or pressing :kbd:`ctrl+d`. Now go to |macOS| and set a shortcut for
|
||||
the :guilabel:`Quick access to kitty` entry.
|
||||
|
||||
.. only:: man
|
||||
|
||||
In Linux, simply assign the above command to a global shortcut in your
|
||||
window manager. In macOS, go to |macOS| and set a shortcut
|
||||
for the :guilabel:`Quick access to kitty` entry.
|
||||
|
||||
Configuration
|
||||
------------------------
|
||||
|
||||
You can configure the appearance and behavior of the quick access window
|
||||
by creating a :file:`quick-access-terminal.conf` file in your
|
||||
:ref:`kitty config folder <confloc>`. In particular, you can use the
|
||||
:opt:`kitty_conf <kitten-quick_access_terminal.kitty_conf>` option to change
|
||||
various kitty settings, just for the quick access window.
|
||||
|
||||
.. note::
|
||||
|
||||
This kitten uses the :doc:`panel kitten </kittens/panel>` under the
|
||||
hood. You can use the :ref:`techniques described there <remote_control_panel>`
|
||||
for remote controlling the quick access window, remember to add
|
||||
``kitty_override allow_remote_control=socket-only`` to
|
||||
:file:`quick-access-terminal.conf` and run the kitten with
|
||||
:option:`--listen-on <kitty +kitten quick_access_terminal --listen-on>`:code:`=unix:/tmp/whatever`
|
||||
to get a fixed socket address.
|
||||
|
||||
.. tip::
|
||||
|
||||
To run programs in the already running quick access terminal, use
|
||||
:option:`--if-running <kitty +kitten quick_access_terminal --if-running>`, for example::
|
||||
|
||||
kitten quick-access-terminal --if-running=new-tab htop
|
||||
|
||||
This will open :program:`htop` in a new tab and show the quick access
|
||||
terminal if it is hidden.
|
||||
|
||||
See below for the supported configuration directives:
|
||||
|
||||
|
||||
.. include:: /generated/conf-kitten-quick_access_terminal.rst
|
||||
|
||||
|
||||
.. include:: /generated/cli-kitten-quick_access_terminal.rst
|
||||
|
||||
|
||||
Sample quick-access-terminal.conf
|
||||
---------------------------------------
|
||||
|
||||
You can download a sample :file:`quick-access-terminal.conf` file with all default settings and
|
||||
comments describing each setting by clicking: :download:`sample quick-access-terminal.conf
|
||||
</generated/conf/quick_access_terminal.conf>`.
|
||||
@@ -0,0 +1,52 @@
|
||||
Remote files
|
||||
==============
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
--------------
|
||||
|
||||
|
||||
|kitty| has the ability to easily *Edit*, *Open* or *Download* files from a
|
||||
computer into which you are SSHed. In your SSH session run::
|
||||
|
||||
ls --hyperlink=auto
|
||||
|
||||
Then hold down :kbd:`Ctrl+Shift` and click the name of the file.
|
||||
|
||||
.. figure:: ../screenshots/remote_file.png
|
||||
:alt: Remote file actions
|
||||
:align: center
|
||||
:width: 100%
|
||||
|
||||
Remote file actions
|
||||
|
||||
|kitty| will ask you what you want to do with the remote file. You can choose
|
||||
to *Edit* it in which case kitty will download it and open it locally in your
|
||||
:envvar:`EDITOR`. As you make changes to the file, they are automatically
|
||||
transferred to the remote computer. Note that this happens without needing
|
||||
to install *any* special software on the server, beyond :program:`ls` that
|
||||
supports hyperlinks.
|
||||
|
||||
.. seealso:: See the :ref:`edit-in-kitty <edit_file>` command
|
||||
|
||||
.. seealso:: See the :doc:`transfer` kitten
|
||||
|
||||
.. versionadded:: 0.19.0
|
||||
|
||||
.. note::
|
||||
For best results, use this kitten with the :doc:`ssh kitten <./ssh>`.
|
||||
Otherwise, nested SSH sessions are not supported. The kitten will always try to copy
|
||||
remote files from the first SSH host. This is because, without the ssh
|
||||
kitten, there is no way for
|
||||
|kitty| to detect and follow a nested SSH session robustly. Use the
|
||||
:doc:`transfer` kitten for such situations.
|
||||
|
||||
.. note::
|
||||
If you have not setup automatic password-less SSH access, and are not using
|
||||
the ssh kitten, then, when editing
|
||||
starts you will be asked to enter your password just once, thereafter the SSH
|
||||
connection will be re-used.
|
||||
|
||||
Similarly, you can choose to save the file to the local computer or download
|
||||
and open it in its default file handler.
|
||||
@@ -0,0 +1,212 @@
|
||||
Truly convenient SSH
|
||||
=========================================
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
----------------
|
||||
|
||||
* Automatic :ref:`shell_integration` on remote hosts
|
||||
|
||||
* Easily :ref:`clone local shell/editor config <real_world_ssh_kitten_config>` on remote hosts
|
||||
|
||||
* Automatic :opt:`re-use of existing connections <kitten-ssh.share_connections>` to avoid connection setup latency
|
||||
|
||||
* Make the kitten binary available in the remote host :opt:`on demand <kitten-ssh.remote_kitty>`
|
||||
|
||||
* Easily :opt:`change terminal colors <kitten-ssh.color_scheme>` when connecting to remote hosts
|
||||
|
||||
* Automatically :opt:`forward the kitty remote control socket <kitten-ssh.forward_remote_control>` to configured hosts
|
||||
|
||||
.. versionadded:: 0.25.0
|
||||
Automatic shell integration, file transfer and reuse of connections
|
||||
|
||||
.. versionadded:: 0.30.0
|
||||
Automatic forwarding of remote control sockets
|
||||
|
||||
The ssh kitten allows you to login easily to remote hosts, and automatically
|
||||
setup the environment there to be as comfortable as your local shell. You can
|
||||
specify environment variables to set on the remote host and files to copy there,
|
||||
making your remote experience just like your local shell. Additionally, it
|
||||
automatically sets up :ref:`shell_integration` on the remote host and copies the
|
||||
kitty terminfo database there.
|
||||
|
||||
The ssh kitten is a thin wrapper around the traditional `ssh <https://man.openbsd.org/ssh>`__
|
||||
command line program and supports all the same options and arguments and configuration.
|
||||
In interactive usage scenarios it is a drop in replacement for :program:`ssh`.
|
||||
To try it out, simply run:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
kitten ssh some-hostname-to-connect-to
|
||||
|
||||
You should end up at a shell prompt on the remote host, with shell integration
|
||||
enabled. If you like it you can add an alias to it in your shell's rc files:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
alias s="kitten ssh"
|
||||
|
||||
So now you can just type ``s hostname`` to connect.
|
||||
|
||||
If you define a mapping in :file:`kitty.conf` such as::
|
||||
|
||||
map f1 new_window_with_cwd
|
||||
|
||||
Then, pressing :kbd:`F1` will open a new window automatically logged into the
|
||||
same host using the ssh kitten, at the same directory.
|
||||
|
||||
The ssh kitten can be configured using the :file:`~/.config/kitty/ssh.conf` file
|
||||
where you can specify environment variables to set on the remote host and files
|
||||
to copy from the local to the remote host. Let's see a quick example:
|
||||
|
||||
.. code-block:: conf
|
||||
|
||||
# Copy the files and directories needed to setup some common tools
|
||||
copy .zshrc .vimrc .vim
|
||||
# Setup some environment variables
|
||||
env SOME_VAR=x
|
||||
# COPIED_VAR will have the same value on the remote host as it does locally
|
||||
env COPIED_VAR=_kitty_copy_env_var_
|
||||
|
||||
# Create some per hostname settings
|
||||
hostname someserver-*
|
||||
copy env-files
|
||||
env SOMETHING=else
|
||||
|
||||
hostname someuser@somehost
|
||||
copy --dest=foo/bar some-file
|
||||
copy --glob some/files.*
|
||||
|
||||
|
||||
See below for full details on the syntax and options of :file:`ssh.conf`.
|
||||
Additionally, you can pass config options on the command line:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
kitten ssh --kitten interpreter=python servername
|
||||
|
||||
The :code:`--kitten` argument can be specified multiple times, with directives
|
||||
from :file:`ssh.conf`. These override the final options used for the matched host, as if they
|
||||
had been appended to the end of the matching section for that host in
|
||||
:file:`ssh.conf`. They apply only to the host being SSHed to by this invocation,
|
||||
so any :opt:`hostname <kitten-ssh.hostname>` directives are ignored.
|
||||
|
||||
.. warning::
|
||||
|
||||
Due to limitations in the design of SSH, any typing you do before the
|
||||
shell prompt appears may be lost. So ideally don't start typing till you see
|
||||
the shell prompt. 😇
|
||||
|
||||
|
||||
.. _real_world_ssh_kitten_config:
|
||||
|
||||
A real world example
|
||||
----------------------
|
||||
|
||||
Suppose you often SSH into a production server, and you would like to setup
|
||||
your shell and editor there using your custom settings. However, other people
|
||||
could SSH in as well and you don't want to clobber their settings. Here is how
|
||||
this could be achieved using the ssh kitten with :program:`zsh` and
|
||||
:program:`vim` as the shell and editor, respectively:
|
||||
|
||||
.. code-block:: conf
|
||||
|
||||
# Have these settings apply to servers in my organization
|
||||
hostname myserver-*
|
||||
|
||||
# Setup zsh to read its files from my-conf/zsh
|
||||
env ZDOTDIR=$HOME/my-conf/zsh
|
||||
copy --dest my-conf/zsh/.zshrc .zshrc
|
||||
copy --dest my-conf/zsh/.zshenv .zshenv
|
||||
# If you use other zsh init files add them in a similar manner
|
||||
|
||||
# Setup vim to read its config from my-conf/vim
|
||||
env VIMINIT=set runtimepath^=$HOME/my-conf/vim runtimepath+=$HOME/my-conf/vim/after | source $HOME/my-conf/vim/vimrc
|
||||
copy --dest my-conf/vim .vim
|
||||
copy --dest my-conf/vim/vimrc .vimrc
|
||||
|
||||
|
||||
How it works
|
||||
----------------
|
||||
|
||||
The ssh kitten works by having SSH transmit and execute a POSIX sh (or
|
||||
:opt:`optionally <kitten-ssh.interpreter>` Python) bootstrap script on the
|
||||
remote host using an :opt:`interpreter <kitten-ssh.interpreter>`. This script
|
||||
reads setup data over the TTY device, which kitty sends as a Base64 encoded
|
||||
compressed tarball. The script extracts it and places the :opt:`files <kitten-ssh.copy>`
|
||||
and sets the :opt:`environment variables <kitten-ssh.env>` before finally
|
||||
launching the :opt:`login shell <kitten-ssh.login_shell>` with :opt:`shell
|
||||
integration <kitten-ssh.shell_integration>` enabled. The data is requested by
|
||||
the kitten over the TTY with a random one time password. kitty reads the request
|
||||
and if the password matches a password pre-stored in shared memory on the
|
||||
localhost by the kitten, the transmission is allowed. If your local
|
||||
`OpenSSH <https://www.openssh.com/>`__ version is >= 8.4 then the data is
|
||||
transmitted instantly without any roundtrip delay.
|
||||
|
||||
.. note::
|
||||
|
||||
When connecting to BSD hosts, it is possible the bootstrap script will fail
|
||||
or run slowly, because the default shells are crippled in various ways.
|
||||
Your best bet is to install Python on the remote, make sure the login shell
|
||||
is something POSIX sh compliant, and use :code:`python` as the
|
||||
:opt:`interpreter <kitten-ssh.interpreter>` in :file:`ssh.conf`.
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
This may or may not work when using terminal multiplexers, depending on
|
||||
whether they passthrough the escape codes and if the values of the
|
||||
environment variables :envvar:`KITTY_PID` and :envvar:`KITTY_WINDOW_ID` are
|
||||
correct in the current session (they can be wrong when connecting to a tmux
|
||||
session running in a different window) and the ssh kitten is run in the
|
||||
currently active multiplexer window.
|
||||
|
||||
.. include:: /generated/conf-kitten-ssh.rst
|
||||
|
||||
|
||||
.. _ssh_copy_command:
|
||||
|
||||
The copy command
|
||||
--------------------
|
||||
|
||||
.. include:: /generated/ssh-copy.rst
|
||||
|
||||
|
||||
.. _manual_terminfo_copy:
|
||||
|
||||
Copying terminfo files manually
|
||||
-------------------------------------
|
||||
|
||||
Sometimes, the ssh kitten can fail, or maybe you dont like to use it. In such
|
||||
cases, the terminfo files can be copied over manually to a server with the
|
||||
following one liner::
|
||||
|
||||
infocmp -a xterm-kitty | ssh myserver tic -x -o \~/.terminfo /dev/stdin
|
||||
|
||||
If you are behind a proxy (like Balabit) that prevents this, or you are SSHing
|
||||
into macOS where the :program:`tic` does not support reading from :file:`STDIN`,
|
||||
you must redirect the first command to a file, copy that to the server and run :program:`tic`
|
||||
manually. If you connect to a server, embedded, or Android system that doesn't
|
||||
have :program:`tic`, copy over your local file terminfo to the other system as
|
||||
:file:`~/.terminfo/x/xterm-kitty`.
|
||||
|
||||
If the server is running a relatively modern Linux distribution and you have
|
||||
root access to it, you could simply install the ``kitty-terminfo`` package on
|
||||
the server to make the terminfo files available.
|
||||
|
||||
Really, the correct solution for this is to convince the OpenSSH maintainers to
|
||||
have :program:`ssh` do this automatically, if possible, when connecting to a
|
||||
server, so that all terminals work transparently.
|
||||
|
||||
If the server is running FreeBSD, or another system that relies on termcap
|
||||
rather than terminfo, you will need to convert the terminfo file on your local
|
||||
machine by running (on local machine with |kitty|)::
|
||||
|
||||
infocmp -CrT0 xterm-kitty
|
||||
|
||||
The output of this command is the termcap description, which should be appended
|
||||
to :file:`/usr/share/misc/termcap` on the remote server. Then run the following
|
||||
command to apply your change (on the server)::
|
||||
|
||||
cap_mkdb /usr/share/misc/termcap
|
||||
@@ -0,0 +1,133 @@
|
||||
Changing kitty colors
|
||||
========================
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
--------------
|
||||
|
||||
|
||||
The themes kitten allows you to easily change color themes, from a collection of
|
||||
over three hundred pre-built themes available at `kitty-themes
|
||||
<https://github.com/kovidgoyal/kitty-themes>`_. To use it, simply run::
|
||||
|
||||
kitten themes
|
||||
|
||||
|
||||
.. image:: ../screenshots/themes.png
|
||||
:alt: The themes kitten in action
|
||||
:width: 600
|
||||
|
||||
The kitten allows you to pick a theme, with live previews of the colors. You can
|
||||
choose between light and dark themes and search by theme name by just typing a
|
||||
few characters from the name.
|
||||
|
||||
The kitten maintains a list of recently used themes to allow quick switching.
|
||||
|
||||
If you want to restore the colors to default, you can do so by choosing the
|
||||
``Default`` theme.
|
||||
|
||||
.. versionadded:: 0.23.0
|
||||
The themes kitten
|
||||
|
||||
|
||||
How it works
|
||||
----------------
|
||||
|
||||
A theme in kitty is just a :file:`.conf` file containing kitty settings.
|
||||
When you select a theme, the kitten simply copies the :file:`.conf` file
|
||||
to :file:`~/.config/kitty/current-theme.conf` and adds an include for
|
||||
:file:`current-theme.conf` to :file:`kitty.conf`. It also comments out any
|
||||
existing color settings in :file:`kitty.conf` so they do not interfere.
|
||||
|
||||
Once that's done, the kitten sends kitty a signal to make it reload its config.
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
If you want to have some color settings in your :file:`kitty.conf` that the
|
||||
theme kitten does not override, move them into a separate conf file and
|
||||
``include`` it into kitty.conf. The include should be placed after the
|
||||
inclusion of :file:`current-theme.conf` so that the settings in it override
|
||||
conflicting settings from :file:`current-theme.conf`.
|
||||
|
||||
|
||||
.. _auto_color_scheme:
|
||||
|
||||
Change color themes automatically when the OS switches between light and dark
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
.. versionadded:: 0.38.0
|
||||
|
||||
You can have kitty automatically change its color theme when the OS switches
|
||||
between dark, light and no-preference modes. In order to do this, run the theme
|
||||
kitten as normal and at the final screen select the option to save your chosen
|
||||
theme as either light, dark, or no-preference. Repeat until you have chosen
|
||||
a theme for each of the three modes. Then, once you restart kitty, it will
|
||||
automatically use your chosen themes depending on the OS color scheme.
|
||||
|
||||
This works by creating three files: :file:`dark-theme.auto.conf`,
|
||||
:file:`light-theme.auto.conf` and :file:`no-preference-theme.auto.conf` in the
|
||||
kitty config directory. When these files exist, kitty queries the OS for its color scheme
|
||||
and uses the appropriate file. Note that the colors in these files override all other
|
||||
colors, and also all background image settings,
|
||||
even those specified using the :option:`kitty --override` command line flag.
|
||||
kitty will also automatically change colors when the OS color scheme changes,
|
||||
for example, during night/day transitions.
|
||||
|
||||
When using these colors, you can still dynamically change colors, but the next
|
||||
time the OS changes its color mode, any dynamic changes will be overridden.
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
On the GNOME desktop, the desktop reports the color preference as no-preference
|
||||
when the "Dark style" is not enabled. So use :file:`no-preference-theme.auto.conf` to
|
||||
select colors for light mode on GNOME. You can manually enable light style
|
||||
with ``gsettings set org.gnome.desktop.interface color-scheme prefer-light``
|
||||
in which case GNOME will report the color scheme as light and kitty will use
|
||||
:file:`light-theme.auto.conf`.
|
||||
|
||||
|
||||
Using your own themes
|
||||
-----------------------
|
||||
|
||||
You can also create your own themes as :file:`.conf` files. Put them in the
|
||||
:file:`themes` sub-directory of the :ref:`kitty config directory <confloc>`,
|
||||
usually, :file:`~/.config/kitty/themes`. The kitten will automatically add them
|
||||
to the list of themes. You can use this to modify the builtin themes, by giving
|
||||
the conf file the name :file:`Some theme name.conf` to override the builtin
|
||||
theme of that name. Here, ``Some theme name`` is the actual builtin theme name, not
|
||||
its file name. Note that after doing so you have to run the kitten and
|
||||
choose that theme once for your changes to be applied.
|
||||
|
||||
|
||||
Contributing new themes
|
||||
-------------------------
|
||||
|
||||
If you wish to contribute a new theme to the kitty theme repository, start by
|
||||
going to the `kitty-themes <https://github.com/kovidgoyal/kitty-themes>`__
|
||||
repository. `Fork it
|
||||
<https://docs.github.com/en/get-started/quickstart/fork-a-repo>`__, and use the
|
||||
file :download:`template.conf
|
||||
<https://github.com/kovidgoyal/kitty-themes/raw/master/template.conf>` as a
|
||||
template when creating your theme. Once you are satisfied with how it looks,
|
||||
`submit a pull request
|
||||
<https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request>`__
|
||||
to have your theme merged into the `kitty-themes
|
||||
<https://github.com/kovidgoyal/kitty-themes>`__ repository, which will make it
|
||||
available in this kitten automatically.
|
||||
|
||||
|
||||
Changing the theme non-interactively
|
||||
---------------------------------------
|
||||
|
||||
You can specify the theme name as an argument when invoking the kitten to have
|
||||
it change to that theme instantly. For example::
|
||||
|
||||
kitten themes --reload-in=all Dimmed Monokai
|
||||
|
||||
Will change the theme to ``Dimmed Monokai`` in all running kitty instances. See
|
||||
below for more details on non-interactive operation.
|
||||
|
||||
.. include:: ../generated/cli-kitten-themes.rst
|
||||
@@ -0,0 +1,87 @@
|
||||
Transfer files
|
||||
================
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
--------------
|
||||
|
||||
|
||||
.. versionadded:: 0.30.0
|
||||
|
||||
.. _rsync: https://en.wikipedia.org/wiki/Rsync
|
||||
|
||||
Transfer files to and from remote computers over the ``TTY`` device itself.
|
||||
This means that file transfer works over nested SSH sessions, serial links,
|
||||
etc. Anywhere you have a terminal device, you can transfer files.
|
||||
|
||||
.. image:: ../screenshots/transfer.png
|
||||
:alt: The transfer kitten at work
|
||||
|
||||
This kitten supports transferring entire directory trees, preserving soft and
|
||||
hard links, file permissions, times, etc. It even supports the rsync_ protocol
|
||||
to transfer only changes to large files.
|
||||
|
||||
.. seealso:: See the :doc:`remote_file` kitten
|
||||
|
||||
Basic usage
|
||||
---------------
|
||||
|
||||
Simply ssh into a remote computer using the :doc:`ssh kitten </kittens/ssh>` and run the this kitten
|
||||
(which the ssh kitten makes available for you on the remote computer
|
||||
automatically). Some illustrative examples are below. To copy a file from a
|
||||
remote computer::
|
||||
|
||||
<local computer> $ kitten ssh my-remote-computer
|
||||
<remote computer> $ kitten transfer some-file /path/on/local/computer
|
||||
|
||||
This, will copy :file:`some-file` from the computer into which you have SSHed
|
||||
to your local computer at :file:`/path/on/local/computer`. kitty will ask you
|
||||
for confirmation before allowing the transfer, so that the file transfer
|
||||
protocol cannot be abused to read/write files on your computer.
|
||||
|
||||
To copy a file from your local computer to the remote computer::
|
||||
|
||||
<local computer> $ kitten ssh my-remote-computer
|
||||
<remote computer> $ kitten transfer --direction=upload /path/on/local/computer remote-file
|
||||
|
||||
For more detailed usage examples, see the command line interface section below.
|
||||
|
||||
.. note::
|
||||
If you dont want to use the ssh kitten, you can install the kitten binary on
|
||||
the remote machine yourself, it is a standalone, statically compiled binary
|
||||
available from the `kitty releases page
|
||||
<https://github.com/kovidgoyal/kitty/releases>`__. Or you can write your own
|
||||
script/program to use the underlying :doc:`file transfer protocol
|
||||
</file-transfer-protocol>`.
|
||||
|
||||
Avoiding the confirmation prompt
|
||||
------------------------------------
|
||||
|
||||
Normally, when you start a file transfer kitty will prompt you for confirmation.
|
||||
This is to ensure that hostile programs running on a remote machine cannot
|
||||
read/write files on your computer without your permission. If the remote machine
|
||||
is trusted, then you can disable the confirmation prompt by:
|
||||
|
||||
#. Setting the :opt:`file_transfer_confirmation_bypass` option to some password.
|
||||
|
||||
#. When invoking the kitten use the :option:`--permissions-bypass
|
||||
<kitty +kitten transfer --permissions-bypass>` to supply the password you set
|
||||
in step one.
|
||||
|
||||
.. warning:: Using a password to bypass confirmation means any software running
|
||||
on the remote machine could potentially learn that password and use it to
|
||||
gain full access to your computer.
|
||||
|
||||
|
||||
Delta transfers
|
||||
-----------------------------------
|
||||
|
||||
This kitten has the ability to use the rsync_ protocol to only transfer the
|
||||
differences between files. To turn it on use the :option:`--transmit-deltas
|
||||
<kitty +kitten transfer --transmit-deltas>` option. Note that this will
|
||||
actually be slower when transferring small files or on a very fast network, because
|
||||
of round trip overhead, so use with care.
|
||||
|
||||
|
||||
.. include:: ../generated/cli-kitten-transfer.rst
|
||||
@@ -0,0 +1,39 @@
|
||||
Unicode input
|
||||
================
|
||||
|
||||
.. only:: man
|
||||
|
||||
Overview
|
||||
--------------
|
||||
|
||||
|
||||
You can input Unicode characters by name, hex code, recently used and even an
|
||||
editable favorites list. Press :sc:`input_unicode_character` to start the
|
||||
unicode input kitten, shown below.
|
||||
|
||||
.. figure:: ../screenshots/unicode.png
|
||||
:alt: A screenshot of the unicode input kitten
|
||||
:align: center
|
||||
:width: 100%
|
||||
|
||||
A screenshot of the unicode input kitten
|
||||
|
||||
In :guilabel:`Code` mode, you enter a Unicode character by typing in the hex
|
||||
code for the character and pressing :kbd:`Enter`. For example, type in ``2716``
|
||||
and press :kbd:`Enter` to get ``✖``. You can also choose a character from the
|
||||
list of recently used characters by typing a leading period ``.`` and then the
|
||||
two character index and pressing :kbd:`Enter`.
|
||||
The :kbd:`Up` and :kbd:`Down` arrow keys can be used to choose the previous and
|
||||
next Unicode symbol respectively.
|
||||
|
||||
In :guilabel:`Name` mode you instead type words from the character name and use
|
||||
the :kbd:`ArrowKeys` / :kbd:`Tab` to select the character from the displayed
|
||||
matches. You can also type a space followed by a period and the index for the
|
||||
match if you don't like to use arrow keys.
|
||||
|
||||
You can switch between modes using either the keys :kbd:`F1` ... :kbd:`F4` or
|
||||
:kbd:`Ctrl+1` ... :kbd:`Ctrl+4` or by pressing :kbd:`Ctrl+[` and :kbd:`Ctrl+]`
|
||||
or by pressing :kbd:`Ctrl+Tab` and :kbd:`Ctrl+Shift+Tab`.
|
||||
|
||||
|
||||
.. include:: ../generated/cli-kitten-unicode_input.rst
|
||||
Reference in new issue
Block a user