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.

97 lines
3.7 KiB

3 years ago
  1. zsh-syntax-highlighting [![Build Status][build-status-image]][build-status]
  2. =======================
  3. **[Fish shell][fish]-like syntax highlighting for [Zsh][zsh].**
  4. *Requirements: zsh 4.3.11+.*
  5. [fish]: https://fishshell.com/
  6. [zsh]: https://www.zsh.org/
  7. This package provides syntax highlighting for the shell zsh. It enables
  8. highlighting of commands whilst they are typed at a zsh prompt into an
  9. interactive terminal. This helps in reviewing commands before running
  10. them, particularly in catching syntax errors.
  11. Some examples:
  12. Before: [![Screenshot #1.1](images/before1-smaller.png)](images/before1.png)
  13. <br/>
  14. After:&nbsp; [![Screenshot #1.2](images/after1-smaller.png)](images/after1.png)
  15. Before: [![Screenshot #2.1](images/before2-smaller.png)](images/before2.png)
  16. <br/>
  17. After:&nbsp; [![Screenshot #2.2](images/after2-smaller.png)](images/after2.png)
  18. Before: [![Screenshot #3.1](images/before3-smaller.png)](images/before3.png)
  19. <br/>
  20. After:&nbsp; [![Screenshot #3.2](images/after3-smaller.png)](images/after3.png)
  21. Before: [![Screenshot #4.1](images/before4-smaller.png)](images/before4-smaller.png)
  22. <br/>
  23. After:&nbsp; [![Screenshot #4.2](images/after4-smaller.png)](images/after4-smaller.png)
  24. How to install
  25. --------------
  26. See [INSTALL.md](INSTALL.md).
  27. FAQ
  28. ---
  29. ### Why must `zsh-syntax-highlighting.zsh` be sourced at the end of the `.zshrc` file?
  30. zsh-syntax-highlighting works by hooking into the Zsh Line Editor (ZLE) and
  31. computing syntax highlighting for the command-line buffer as it stands at the
  32. time z-sy-h's hook is invoked.
  33. In zsh 5.2 and older,
  34. `zsh-syntax-highlighting.zsh` hooks into ZLE by wrapping ZLE widgets. It must
  35. be sourced after all custom widgets have been created (i.e., after all `zle -N`
  36. calls and after running `compinit`) in order to be able to wrap all of them.
  37. Widgets created after z-sy-h is sourced will work, but will not update the
  38. syntax highlighting.
  39. In zsh newer than 5.8 (not including 5.8 itself),
  40. zsh-syntax-highlighting uses the `add-zle-hook-widget` facility to install
  41. a `zle-line-pre-redraw` hook. Hooks are run in order of registration,
  42. therefore, z-sy-h must be sourced (and register its hook) after anything else
  43. that adds hooks that modify the command-line buffer.
  44. ### Does syntax highlighting work during incremental history search?
  45. Highlighting the command line during an incremental history search (by default bound to
  46. to <kbd>Ctrl+R</kbd> in zsh's emacs keymap) requires zsh 5.4 or newer.
  47. Under zsh versions older than 5.4, the zsh-default [underlining][zshzle-Character-Highlighting]
  48. of the matched portion of the buffer remains available, but zsh-syntax-highlighting's
  49. additional highlighting is unavailable. (Those versions of zsh do not provide
  50. enough information to allow computing the highlighting correctly.)
  51. See issues [#288][i288] and [#415][i415] for details.
  52. [zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
  53. [i288]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/288
  54. [i415]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/415
  55. ### How are new releases announced?
  56. There is currently no "push" announcements channel. However, the following
  57. alternatives exist:
  58. - GitHub's RSS feed of releases: https://github.com/zsh-users/zsh-syntax-highlighting/releases.atom
  59. - An anitya entry: https://release-monitoring.org/project/7552/
  60. How to tweak
  61. ------------
  62. Syntax highlighting is done by pluggable highlighter scripts. See the
  63. [documentation on highlighters](docs/highlighters.md) for details and
  64. configuration settings.
  65. [build-status]: https://github.com/zsh-users/zsh-syntax-highlighting/actions
  66. [build-status-image]: https://github.com/zsh-users/zsh-syntax-highlighting/workflows/Tests/badge.svg