overview.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. Overview
  2. ==============
  3. Design philosophy
  4. -------------------
  5. |kitty| is designed for power keyboard users. To that end all its controls work
  6. with the keyboard (although it fully supports mouse interactions as well). Its
  7. configuration is a simple, human editable, single file for easy reproducibility
  8. (I like to store configuration in source control).
  9. The code in |kitty| is designed to be simple, modular and hackable. It is
  10. written in a mix of C (for performance sensitive parts), Python (for easy
  11. extensibility and flexibility of the UI) and Go (for the command line
  12. :term:`kittens`). It does not depend on any large and complex UI toolkit,
  13. using only OpenGL for rendering everything.
  14. Finally, |kitty| is designed from the ground up to support all modern terminal
  15. features, such as Unicode, true color, bold/italic fonts, text formatting, etc.
  16. It even extends existing text formatting escape codes, to add support for
  17. features not available elsewhere, such as colored and styled (curly) underlines.
  18. One of the design goals of |kitty| is to be easily extensible so that new
  19. features can be added in the future with relatively little effort.
  20. .. include:: basic.rst
  21. Configuring kitty
  22. -------------------
  23. |kitty| is highly configurable, everything from keyboard shortcuts to painting
  24. frames-per-second. Press :sc:`edit_config_file` in kitty to open its fully
  25. commented sample config file in your text editor. For details see the
  26. :doc:`configuration docs <conf>`.
  27. .. toctree::
  28. :hidden:
  29. conf
  30. .. _layouts:
  31. Layouts
  32. ----------
  33. A :term:`layout` is an arrangement of multiple :term:`kitty windows <window>`
  34. inside a top-level :term:`OS window <os_window>`. The layout manages all its
  35. windows automatically, resizing and moving them as needed. You can create a new
  36. :term:`window` using the :sc:`new_window` key combination.
  37. Currently, there are seven layouts available:
  38. * **Fat** -- One (or optionally more) windows are shown full width on the top,
  39. the rest of the windows are shown side-by-side on the bottom
  40. * **Grid** -- All windows are shown in a grid
  41. * **Horizontal** -- All windows are shown side-by-side
  42. * **Splits** -- Windows arranged in arbitrary patterns created using horizontal
  43. and vertical splits
  44. * **Stack** -- Only a single maximized window is shown at a time
  45. * **Tall** -- One (or optionally more) windows are shown full height on the
  46. left, the rest of the windows are shown one below the other on the right
  47. * **Vertical** -- All windows are shown one below the other
  48. By default, all layouts are enabled and you can switch between layouts using
  49. the :sc:`next_layout` key combination. You can also create shortcuts to select
  50. particular layouts, and choose which layouts you want to enable, see
  51. :ref:`conf-kitty-shortcuts.layout` for examples. The first layout listed in
  52. :opt:`enabled_layouts` becomes the default layout.
  53. For more details on the layouts and how to use them see :doc:`the documentation
  54. <layouts>`.
  55. .. toctree::
  56. :hidden:
  57. layouts
  58. Extending kitty
  59. ------------------
  60. kitty has a powerful framework for scripting. You can create small terminal
  61. programs called :doc:`kittens <kittens_intro>`. These can be used to add features
  62. to kitty, for example, :doc:`editing remote files <kittens/remote_file>` or
  63. :doc:`inputting Unicode characters <kittens/unicode_input>`. They can also be
  64. used to create programs that leverage kitty's powerful features, for example,
  65. :doc:`viewing images <kittens/icat>` or :doc:`diffing files with image support
  66. <kittens/diff>`.
  67. You can :doc:`create your own kittens to scratch your own itches
  68. <kittens/custom>`.
  69. For a list of all the builtin kittens, :ref:`see here <kittens>`.
  70. Additionally, you can use the :ref:`watchers <Watchers>` framework
  71. to create Python scripts that run in response to various events such as windows
  72. being resized, closing, having their titles changed, etc.
  73. .. toctree::
  74. :hidden:
  75. kittens_intro
  76. Remote control
  77. ------------------
  78. |kitty| has a very powerful system that allows you to control it from the
  79. :doc:`shell prompt, even over SSH <remote-control>`. You can change colors,
  80. fonts, open new :term:`windows <window>`, :term:`tabs <tab>`, set their titles,
  81. change window layout, get text from one window and send text to another, etc.
  82. The possibilities are endless. See the :doc:`tutorial <remote-control>` to get
  83. started.
  84. .. toctree::
  85. :hidden:
  86. remote-control
  87. .. _sessions:
  88. Startup Sessions
  89. ------------------
  90. You can control the :term:`tabs <tab>`, :term:`kitty window <window>` layout,
  91. working directory, startup programs, etc. by creating a *session* file and using
  92. the :option:`kitty --session` command line flag or the :opt:`startup_session`
  93. option in :file:`kitty.conf`. An example, showing all available commands:
  94. .. code-block:: session
  95. # Set the layout for the current tab
  96. layout tall
  97. # Set the working directory for windows in the current tab
  98. cd ~
  99. # Create a window and run the specified command in it
  100. launch zsh
  101. # Create a window with some environment variables set and run vim in it
  102. launch --env FOO=BAR vim
  103. # Set the title for the next window
  104. launch --title "Chat with x" irssi --profile x
  105. # Run a short lived command and see its output
  106. launch --hold message-of-the-day
  107. # Create a new tab
  108. # The part after new_tab is the optional tab title which will be displayed in
  109. # the tab bar, if omitted, the title of the active window will be used instead.
  110. new_tab my tab
  111. cd ~/somewhere
  112. # Set the layouts allowed in this tab
  113. enabled_layouts tall,stack
  114. # Set the current layout
  115. layout stack
  116. launch zsh
  117. # Create a new OS window
  118. # Any definitions specified before the first new_os_window will apply to first OS window.
  119. new_os_window
  120. # Set new window size to 80x24 cells
  121. os_window_size 80c 24c
  122. # Set the --class for the new OS window
  123. os_window_class mywindow
  124. # Change the OS window state to normal, fullscreen, maximized or minimized
  125. os_window_state normal
  126. launch sh
  127. # Resize the current window (see the resize_window action for details)
  128. resize_window wider 2
  129. # Make the current window the active (focused) window in its tab
  130. focus
  131. # Make the current OS Window the globally active window (not supported on Wayland)
  132. focus_os_window
  133. launch emacs
  134. # Create a complex layout using multiple splits. Creates two columns of
  135. # windows with two windows in each column. The windows in the first column are
  136. # split 50:50. In the second column the windows are not evenly split.
  137. new_tab complex tab
  138. layout splits
  139. # First window, set a user variable on it so we can focus it later
  140. launch --var window=first
  141. # Create the second column by splitting the first window vertically
  142. launch --location=vsplit
  143. # Create the third window in the second column by splitting the second window horizontally
  144. # Make it take 40% of the height instead of 50%
  145. launch --location=hsplit --bias=40
  146. # Go back to focusing the first window, so that we can split it
  147. focus_matching_window var:window=first
  148. # Create the final window in the first column
  149. launch --location=hsplit
  150. .. note::
  151. The :doc:`launch <launch>` command when used in a session file cannot create
  152. new OS windows, or tabs.
  153. .. note::
  154. Environment variables of the form :code:`${NAME}` or :code:`$NAME` are
  155. expanded in the session file, except in the *arguments* (not options) to the
  156. launch command.
  157. Creating tabs/windows
  158. -------------------------------
  159. kitty can be told to run arbitrary programs in new :term:`tabs <tab>`,
  160. :term:`windows <window>` or :term:`overlays <overlay>` at a keypress.
  161. To learn how to do this, see :doc:`here <launch>`.
  162. .. toctree::
  163. :hidden:
  164. launch
  165. Mouse features
  166. -------------------
  167. * You can click on a URL to open it in a browser.
  168. * You can double click to select a word and then drag to select more words.
  169. * You can triple click to select a line and then drag to select more lines.
  170. * You can triple click while holding :kbd:`Ctrl+Alt` to select from clicked
  171. point to end of line.
  172. * You can right click to extend a previous selection.
  173. * You can hold down :kbd:`Ctrl+Alt` and drag with the mouse to select in
  174. columns.
  175. * Selecting text automatically copies it to the primary clipboard (on platforms
  176. with a primary clipboard).
  177. * You can middle click to paste from the primary clipboard (on platforms with a
  178. primary clipboard).
  179. * You can right click while holding :kbd:`Ctrl+Shift` to open the output of the
  180. clicked on command in a pager (requires :ref:`shell_integration`)
  181. * You can select text with kitty even when a terminal program has grabbed the
  182. mouse by holding down the :kbd:`Shift` key
  183. All these actions can be customized in :file:`kitty.conf` as described
  184. :ref:`here <conf-kitty-mouse.mousemap>`.
  185. You can also customize what happens when clicking on :term:`hyperlinks` in
  186. kitty, having it open files in your editor, download remote files, open things
  187. in your browser, etc.
  188. For details, see :doc:`here <open_actions>`.
  189. .. toctree::
  190. :hidden:
  191. open_actions
  192. Font control
  193. -----------------
  194. |kitty| has extremely flexible and powerful font selection features. You can
  195. specify individual families for the regular, bold, italic and bold+italic fonts.
  196. You can even specify specific font families for specific ranges of Unicode
  197. characters. This allows precise control over text rendering. It can come in
  198. handy for applications like powerline, without the need to use patched fonts.
  199. See the various font related configuration directives in
  200. :ref:`conf-kitty-fonts`.
  201. .. _scrollback:
  202. The scrollback buffer
  203. -----------------------
  204. |kitty| supports scrolling back to view history, just like most terminals. You
  205. can use either keyboard shortcuts or the mouse scroll wheel to do so. While
  206. you are browsing the scrollback a :opt:`small indicator <scrollback_indicator_opacity>`
  207. is displayed along the right edge of the window to show how far back you are.
  208. However, |kitty| has an extra, neat feature. Sometimes you need to explore the scrollback
  209. buffer in more detail, maybe search for some text or refer to it side-by-side
  210. while typing in a follow-up command. |kitty| allows you to do this by pressing
  211. the :sc:`show_scrollback` shortcut, which will open the scrollback buffer in
  212. your favorite pager program (which is :program:`less` by default). Colors and
  213. text formatting are preserved. You can explore the scrollback buffer comfortably
  214. within the pager.
  215. Additionally, you can pipe the contents of the scrollback buffer to an
  216. arbitrary, command running in a new :term:`window`, :term:`tab` or
  217. :term:`overlay`. For example::
  218. map f1 launch --stdin-source=@screen_scrollback --stdin-add-formatting less +G -R
  219. Would open the scrollback buffer in a new :term:`window` when you press the
  220. :kbd:`F1` key. See :sc:`show_scrollback <show_scrollback>` for details.
  221. If you want to use it with an editor such as :program:`vim` to get more powerful
  222. features, see for example, `kitty-scrollback.nvim
  223. <https://github.com/mikesmithgh/kitty-scrollback.nvim>`__ or `kitty-grab <https://github.com/yurikhan/kitty_grab>`__
  224. or see more tips for using various editor programs, in :iss:`this thread <719>`.
  225. If you wish to store very large amounts of scrollback to view using the piping
  226. or :sc:`show_scrollback <show_scrollback>` features, you can use the
  227. :opt:`scrollback_pager_history_size` option.
  228. Integration with shells
  229. ---------------------------------
  230. kitty has the ability to integrate closely within common shells, such as `zsh
  231. <https://www.zsh.org/>`__, `fish <https://fishshell.com>`__ and `bash
  232. <https://www.gnu.org/software/bash/>`__ to enable features such as jumping to
  233. previous prompts in the scrollback, viewing the output of the last command in
  234. :program:`less`, using the mouse to move the cursor while editing prompts, etc.
  235. See :doc:`shell-integration` for details.
  236. .. toctree::
  237. :hidden:
  238. shell-integration
  239. .. _cpbuf:
  240. Multiple copy/paste buffers
  241. -----------------------------
  242. In addition to being able to copy/paste from the system clipboard, in |kitty|
  243. you can also setup an arbitrary number of copy paste buffers. To do so, simply
  244. add something like the following to your :file:`kitty.conf`::
  245. map f1 copy_to_buffer a
  246. map f2 paste_from_buffer a
  247. This will allow you to press :kbd:`F1` to copy the current selection to an
  248. internal buffer named ``a`` and :kbd:`F2` to paste from that buffer. The buffer
  249. names are arbitrary strings, so you can define as many such buffers as you need.
  250. Marks
  251. -------------
  252. kitty has the ability to mark text on the screen based on regular expressions.
  253. This can be useful to highlight words or phrases when browsing output from long
  254. running programs or similar. To learn how this feature works, see :doc:`marks`.
  255. .. toctree::
  256. :hidden:
  257. marks