You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

290 lines
9.9 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. [![paypal](https://img.shields.io/badge/-Donate-yellow.svg?longCache=true&style=for-the-badge)](https://www.paypal.me/ZdharmaInitiative)
  2. [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=D54B3S7C6HGME)
  3. [![patreon](https://img.shields.io/badge/-Patreon-orange.svg?longCache=true&style=for-the-badge)](https://www.patreon.com/psprint)
  4. <br/>New: You can request a feature when donating, even fancy or advanced ones get implemented this way. [There are
  5. reports](DONATIONS.md) about what is being done with the money received.
  6. # Fast Syntax Highlighting (F-Sy-H)
  7. Feature rich syntax highlighting for Zsh.
  8. <div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
  9. <img
  10. src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/highlight-much.png"
  11. alt="image could not be loaded"
  12. style="color:red;background-color:black;font-weight:bold"
  13. />
  14. </div>
  15. ### Table of Contents
  16. - [News](#news)
  17. - [Installation](#installation)
  18. - [Features](#features)
  19. - [Performance](#performance)
  20. - [IRC Channel](#irc-channel)
  21. ### Other Contents
  22. - [License](https://github.com/zdharma/fast-syntax-highlighting/blob/master/LICENSE)
  23. - [Changelog](https://github.com/zdharma/fast-syntax-highlighting/blob/master/CHANGELOG.md)
  24. - [Theme Guide](https://github.com/zdharma/fast-syntax-highlighting/blob/master/THEME_GUIDE.md)
  25. - [Chroma Guide](https://github.com/zdharma/fast-syntax-highlighting/blob/master/CHROMA_GUIDE.adoc)
  26. # News
  27. * 15-06-2019
  28. - A new architecture for defining the highlighting for **specific commands**: it now
  29. uses **abstract definitions** instead of **top-down, regular code**. The first effect
  30. is the highlighting for the `git` command it is now **maximally faithful**, it
  31. follows the `git` command almost completely.
  32. [Screencast](https://asciinema.org/a/253411)
  33. # Installation
  34. ### Manual
  35. Clone the Repository.
  36. ```zsh
  37. git clone https://github.com/zdharma/fast-syntax-highlighting ~/path/to/fsh
  38. ```
  39. And add the following to your `zshrc` file.
  40. ```zsh
  41. source ~/path/to/fsh/fast-syntax-highlighting.plugin.zsh
  42. ```
  43. ### Zinit
  44. Add the following to your `zshrc` file.
  45. ```zsh
  46. zinit light zdharma/fast-syntax-highlighting
  47. ```
  48. Here's an example of how to load the plugin together with a few other popular
  49. ones with the use of
  50. [Turbo](https://zdharma.org/zinit/wiki/INTRODUCTION/#turbo_mode_zsh_62_53),
  51. i.e.: speeding up the Zsh startup by loading the plugin right after the first
  52. prompt, in background:
  53. ```zsh
  54. zinit wait lucid for \
  55. atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay" \
  56. zdharma/fast-syntax-highlighting \
  57. blockf \
  58. zsh-users/zsh-completions \
  59. atload"!_zsh_autosuggest_start" \
  60. zsh-users/zsh-autosuggestions
  61. ```
  62. ### Antigen
  63. Add the following to your `zshrc` file.
  64. ```zsh
  65. antigen bundle zdharma/fast-syntax-highlighting
  66. ```
  67. ### Zgen
  68. Add the following to your `.zshrc` file in the same place you're doing
  69. your other `zgen load` calls in.
  70. ```zsh
  71. zgen load zdharma/fast-syntax-highlighting
  72. ```
  73. ### Oh-My-Zsh
  74. Clone the Repository.
  75. ```zsh
  76. git clone https://github.com/zdharma/fast-syntax-highlighting.git \
  77. ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting
  78. ```
  79. And add `fast-syntax-highlighting` to your plugin list.
  80. # Features
  81. ### Themes
  82. Switch themes via `fast-theme {theme-name}`.
  83. <div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
  84. <img
  85. src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/theme.png"
  86. alt="image could not be loaded"
  87. style="color:red;background-color:black;font-weight:bold"
  88. />
  89. </div>
  90. Run `fast-theme -t {theme-name}` option to obtain the snippet above.
  91. Run `fast-theme -l` to list available themes.
  92. ### Variables
  93. Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line):
  94. <div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
  95. <img
  96. src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/parameter.png"
  97. alt="image could not be loaded"
  98. style="color:red;background-color:black;font-weight:bold"
  99. />
  100. </div>
  101. <div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
  102. <img
  103. src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/in_string.png"
  104. alt="image could not be loaded"
  105. style="color:red;background-color:black;font-weight:bold"
  106. />
  107. </div>
  108. ### Brackets
  109. <div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
  110. <img
  111. src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/brackets.gif"
  112. alt="image could not be loaded"
  113. style="color:red;background-color:black;font-weight:bold"
  114. />
  115. </div>
  116. ### Conditions
  117. Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line):
  118. <div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
  119. <img
  120. src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/cplx_cond.png"
  121. alt="image could not be loaded"
  122. style="color:red;background-color:black;font-weight:bold"
  123. />
  124. </div>
  125. ### Strings
  126. Exact highlighting that recognizes quotings.
  127. <div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
  128. <img
  129. src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/ideal-string.png"
  130. alt="image could not be loaded"
  131. style="color:red;background-color:black;font-weight:bold"
  132. />
  133. </div>
  134. ### here-strings
  135. <div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
  136. <img
  137. src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/herestring.png"
  138. alt="image could not be loaded"
  139. style="color:red;background-color:black;font-weight:bold"
  140. />
  141. </div>
  142. ### `exec` descriptor-variables
  143. Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line):
  144. <div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
  145. <img
  146. src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/execfd_cmp.png"
  147. alt="image could not be loaded"
  148. style="color:red;background-color:black;font-weight:bold"
  149. />
  150. </div>
  151. ### for-loops and alternate syntax (brace `{`/`}` blocks)
  152. <div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
  153. <img
  154. src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/for-loop-cmp.png"
  155. alt="image could not be loaded"
  156. style="color:red;background-color:black;font-weight:bold"
  157. />
  158. </div>
  159. ### Function definitions
  160. Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper 2 lines):
  161. <div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
  162. <img
  163. src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/function.png"
  164. alt="image could not be loaded"
  165. style="color:red;background-color:black;font-weight:bold"
  166. />
  167. </div>
  168. ### Recursive `eval` and `$( )` highlighting
  169. Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line):
  170. <div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
  171. <img
  172. src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/eval_cmp.png"
  173. alt="image could not be loaded"
  174. style="color:red;background-color:black;font-weight:bold"
  175. />
  176. </div>
  177. ### Chroma functions
  178. Highlighting that is specific for a given command.
  179. <div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
  180. <img
  181. src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/git_chroma.png"
  182. alt="image could not be loaded"
  183. style="color:red;background-color:black;font-weight:bold"
  184. />
  185. </div>
  186. The [chromas](https://github.com/zdharma/fast-syntax-highlighting/tree/master/chroma)
  187. that are enabled by default can be found
  188. [here](https://github.com/zdharma/fast-syntax-highlighting/blob/master/fast-highlight#L166).
  189. ### Math-mode highlighting
  190. <div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
  191. <img
  192. src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/math.gif"
  193. alt="image could not be loaded"
  194. style="color:red;background-color:black;font-weight:bold"
  195. />
  196. </div>
  197. ### Zcalc highlighting
  198. <div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
  199. <img
  200. src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/zcalc.png"
  201. alt="image could not be loaded"
  202. style="color:red;background-color:black;font-weight:bold"
  203. />
  204. </div>
  205. # Performance
  206. Performance differences can be observed in this Asciinema recording, where a `10 kB` function is being edited.
  207. <div style="width:100%;background-color:#121314;border:3px solid #121314;border-radius:6px;margin:5px 0;padding:2px 5px">
  208. <a href="https://asciinema.org/a/112367">
  209. <img src="https://asciinema.org/a/112367.png" alt="asciicast">
  210. </a>
  211. </div>
  212. ## IRC Channel
  213. Channel `#zinit@freenode` is a support place for all author's projects. Connect to:
  214. [chat.freenode.net:6697](ircs://chat.freenode.net:6697/%23zinit) (SSL) or [chat.freenode.net:6667](irc://chat.freenode.net:6667/%23zinit)
  215. and join #zinit.
  216. Following is a quick access via Webchat [![IRC](https://kiwiirc.com/buttons/chat.freenode.net/zinit.png)](https://kiwiirc.com/client/chat.freenode.net:+6697/#zinit)