pipe.rst 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. :orphan:
  2. Working with the screen and history buffer contents
  3. ======================================================
  4. .. warning::
  5. The pipe action has been deprecated in favor of the
  6. :doc:`launch <launch>` action which is more powerful.
  7. You can pipe the contents of the current screen and history buffer as
  8. :file:`STDIN` to an arbitrary program using the ``pipe`` function. The program
  9. can be displayed in a kitty window or overlay.
  10. For example, the following in :file:`kitty.conf` will open the scrollback
  11. buffer in less in an overlay window, when you press :kbd:`F1`::
  12. map f1 pipe @ansi overlay less +G -R
  13. The syntax of the ``pipe`` function is::
  14. pipe <input placeholder> <destination window type> <command line to run>
  15. The piping environment
  16. --------------------------
  17. The program to which the data is piped has a special environment variable
  18. declared, ``KITTY_PIPE_DATA`` whose contents are::
  19. KITTY_PIPE_DATA={scrolled_by}:{cursor_x},{cursor_y}:{lines},{columns}
  20. where ``scrolled_by`` is the number of lines kitty is currently scrolled by,
  21. ``cursor_(x|y)`` is the position of the cursor on the screen with ``(1,1)``
  22. being the top left corner and ``{lines},{columns}`` being the number of rows
  23. and columns of the screen.
  24. You can choose where to run the pipe program:
  25. ``overlay``
  26. An overlay window over the current kitty window
  27. ``window``
  28. A new kitty window
  29. ``os_window``
  30. A new top-level window
  31. ``tab``
  32. A new window in a new tab
  33. ``clipboard, primary``
  34. Copy the text directly to the clipboard. In this case the specified program
  35. is not run, so use some dummy program name for it.
  36. ``none``
  37. Run it in the background
  38. Input placeholders
  39. --------------------
  40. There are various different kinds of placeholders
  41. ``@selection``
  42. Plain text, currently selected text
  43. ``@text``
  44. Plain text, current screen + scrollback buffer
  45. ``@ansi``
  46. Text with formatting, current screen + scrollback buffer
  47. ``@screen``
  48. Plain text, only current screen
  49. ``@ansi_screen``
  50. Text with formatting, only current screen
  51. ``@alternate``
  52. Plain text, secondary screen. The secondary screen is the screen not currently displayed. For
  53. example if you run a fullscreen terminal application, the secondary screen will
  54. be the screen you return to when quitting the application.
  55. ``@ansi_alternate``
  56. Text with formatting, secondary screen.
  57. ``@alternate_scrollback``
  58. Plain text, secondary screen + scrollback, if any.
  59. ``@ansi_alternate_scrollback``
  60. Text with formatting, secondary screen + scrollback, if any.
  61. ``none``
  62. No input
  63. You can also add the suffix ``_wrap`` to the placeholder, in which case kitty
  64. will insert the carriage return at every line wrap location (where long lines
  65. are wrapped at screen edges). This is useful if you want to pipe to program
  66. that wants to duplicate the screen layout of the screen.