diff.rst 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. kitty-diff
  2. ================================================================================
  3. *A fast side-by-side diff tool with syntax highlighting and images*
  4. .. highlight:: sh
  5. Major Features
  6. -----------------
  7. .. container:: major-features
  8. * Displays diffs side-by-side in the kitty terminal
  9. * Does syntax highlighting of the displayed diffs, asynchronously, for
  10. maximum speed
  11. * Displays images as well as text diffs, even over SSH
  12. * Does recursive directory diffing
  13. .. figure:: ../screenshots/diff.png
  14. :alt: Screenshot, showing a sample diff
  15. :align: center
  16. :width: 100%
  17. Screenshot, showing a sample diff
  18. Installation
  19. ---------------
  20. Simply :ref:`install kitty <quickstart>`.
  21. Usage
  22. --------
  23. In the kitty terminal, run::
  24. kitten diff file1 file2
  25. to see the diff between :file:`file1` and :file:`file2`.
  26. Create an alias in your shell's startup file to shorten the command, for
  27. example:
  28. .. code-block:: sh
  29. alias d="kitten diff"
  30. Now all you need to do to diff two files is::
  31. d file1 file2
  32. You can also pass directories instead of files to see the recursive diff of the
  33. directory contents.
  34. Keyboard controls
  35. ----------------------
  36. =========================== ===========================
  37. Action Shortcut
  38. =========================== ===========================
  39. Quit :kbd:`Q`, :kbd:`Esc`
  40. Scroll line up :kbd:`K`, :kbd:`Up`
  41. Scroll line down :kbd:`J`, :kbd:`Down`
  42. Scroll page up :kbd:`PgUp`
  43. Scroll page down :kbd:`PgDn`
  44. Scroll to top :kbd:`Home`
  45. Scroll to bottom :kbd:`End`
  46. Scroll to next page :kbd:`Space`, :kbd:`PgDn`
  47. Scroll to previous page :kbd:`PgUp`
  48. Scroll to next change :kbd:`N`
  49. Scroll to previous change :kbd:`P`
  50. Increase lines of context :kbd:`+`
  51. Decrease lines of context :kbd:`-`
  52. All lines of context :kbd:`A`
  53. Restore default context :kbd:`=`
  54. Search forwards :kbd:`/`
  55. Search backwards :kbd:`?`
  56. Clear search :kbd:`Esc`
  57. Scroll to next match :kbd:`>`, :kbd:`.`
  58. Scroll to previous match :kbd:`<`, :kbd:`,`
  59. Copy selection to clipboard :kbd:`y`
  60. Copy selection or exit :kbd:`Ctrl+C`
  61. =========================== ===========================
  62. Integrating with git
  63. -----------------------
  64. Add the following to :file:`~/.gitconfig`:
  65. .. code-block:: ini
  66. [diff]
  67. tool = kitty
  68. guitool = kitty.gui
  69. [difftool]
  70. prompt = false
  71. trustExitCode = true
  72. [difftool "kitty"]
  73. cmd = kitten diff $LOCAL $REMOTE
  74. [difftool "kitty.gui"]
  75. cmd = kitten diff $LOCAL $REMOTE
  76. Now to use kitty-diff to view git diffs, you can simply do::
  77. git difftool --no-symlinks --dir-diff
  78. Once again, creating an alias for this command is useful.
  79. Why does this work only in kitty?
  80. ----------------------------------------
  81. The diff kitten makes use of various features that are :doc:`kitty only
  82. </protocol-extensions>`, such as the :doc:`kitty graphics protocol
  83. </graphics-protocol>`, the :doc:`extended keyboard protocol
  84. </keyboard-protocol>`, etc. It also leverages terminal program infrastructure
  85. I created for all of kitty's other kittens to reduce the amount of code needed
  86. (the entire implementation is under 3000 lines of code).
  87. And fundamentally, it's kitty only because I wrote it for myself, and I am
  88. highly unlikely to use any other terminals :)
  89. Configuration
  90. ------------------------
  91. You can configure the colors used, keyboard shortcuts, the diff implementation,
  92. the default lines of context, etc. by creating a :file:`diff.conf` file in your
  93. :ref:`kitty config folder <confloc>`. See below for the supported configuration
  94. directives.
  95. .. include:: /generated/conf-kitten-diff.rst
  96. .. include:: /generated/cli-kitten-diff.rst
  97. Sample diff.conf
  98. -----------------
  99. You can download a sample :file:`diff.conf` file with all default settings and
  100. comments describing each setting by clicking: :download:`sample diff.conf
  101. </generated/conf/diff.conf>`.