700c0e18fe
% git co HEAD^ && repeat 3 { zsh -f tests/test-zprof.zsh main | tee … | grep -w _zsh_highlight | head -n1 } HEAD is now at 64e3651 'main': Optimize a hot path. 19) 1 28765.13 28765.13 100.00% 5.57 5.57 0.02% _zsh_highlight 19) 1 28566.46 28566.46 100.00% 5.91 5.91 0.02% _zsh_highlight 19) 1 28248.12 28248.12 100.00% 5.57 5.57 0.02% _zsh_highlight ---- This commit has been rebased. The above statistics were measured after the rebase. The below statistics had been measured before the rebase. Before this patch: num calls time self name ----------------------------------------------------------------------------------- 1) 3 33410.81 11136.94 98.51% 19277.07 6425.69 56.84% _zsh_highlight_main_highlighter_highlight_list 19) 1 33916.21 33916.21 100.00% 5.27 5.27 0.02% _zsh_highlight With this patch: num calls time self name ----------------------------------------------------------------------------------- 1) 3 27167.49 9055.83 98.17% 18754.77 6251.59 67.77% _zsh_highlight_main_highlighter_highlight_list 19) 1 27674.40 27674.40 100.00% 5.39 5.39 0.02% _zsh_highlight And if test-zprof.zsh is changed to not set interactivecomments: num calls time self name ----------------------------------------------------------------------------------- 1) 13360 36029.12 2.70 83.56% 30304.23 2.27 70.28% _zsh_highlight_main_highlighter_highlight_argument 21) 1 43117.76 43117.76 100.00% 4.52 4.52 0.01% _zsh_highlight num calls time self name ----------------------------------------------------------------------------------- 1) 13360 14782.89 1.11 68.12% 9163.42 0.69 42.23% _zsh_highlight_main_highlighter_highlight_argument 21) 1 21699.93 21699.93 100.00% 4.17 4.17 0.02% _zsh_highlight |
||
---|---|---|
docs | ||
highlighters | ||
images | ||
tests | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.revision-hash | ||
.travis.yml | ||
.version | ||
changelog.md | ||
COPYING.md | ||
HACKING.md | ||
INSTALL.md | ||
Makefile | ||
README.md | ||
release.md | ||
zsh-syntax-highlighting.plugin.zsh | ||
zsh-syntax-highlighting.zsh |
zsh-syntax-highlighting
Fish shell-like syntax highlighting for Zsh.
Requirements: zsh 4.3.11+.
This package provides syntax highlighting for the shell zsh. It enables highlighting of commands whilst they are typed at a zsh prompt into an interactive terminal. This helps in reviewing commands before running them, particularly in catching syntax errors.
Some examples:
How to install
See INSTALL.md.
FAQ
Why must zsh-syntax-highlighting.zsh
be sourced at the end of the .zshrc
file?
zsh-syntax-highlighting.zsh
wraps ZLE widgets. It must be sourced after all
custom widgets have been created (i.e., after all zle -N
calls and after
running compinit
). Widgets created later will work, but will not update the
syntax highlighting.
Does syntax highlighting work during incremental history search?
Highlighting the command line during an incremental history search (by default bound to to Ctrl+R in zsh's emacs keymap) requires zsh 5.4 or newer.
Under zsh versions older than 5.4, the zsh-default underlining of the matched portion of the buffer remains available, but zsh-syntax-highlighting's additional highlighting is unavailable. (Those versions of zsh do not provide enough information to allow computing the highlighting correctly.)
See issues #288 and #415 for details.
How are new releases announced?
There is currently no "push" announcements channel. However, the following alternatives exist:
- GitHub's RSS feed of releases: https://github.com/zsh-users/zsh-syntax-highlighting/releases.atom
- An anitya entry: https://release-monitoring.org/project/7552/
How to tweak
Syntax highlighting is done by pluggable highlighter scripts. See the documentation on highlighters for details and configuration settings.