2a30d4fb5a
On the test case, the behaviour was as follows: +highlighters/main/main-highlighter.zsh:733> _zsh_highlight_main_highlighter__try_expand_parameter '$1' +highlighters/main/main-highlighter.zsh:432> local arg='$1' +highlighters/main/main-highlighter.zsh:433> unset reply +highlighters/main/main-highlighter.zsh:439> local -a match mbegin mend +highlighters/main/main-highlighter.zsh:440> local MATCH +highlighters/main/main-highlighter.zsh:440> integer MBEGIN MEND +highlighters/main/main-highlighter.zsh:441> local parameter_name +highlighters/main/main-highlighter.zsh:442> local -a words +highlighters/main/main-highlighter.zsh:443> [[ '$' != \$ ]] +highlighters/main/main-highlighter.zsh:446> [[ 1 == { ]] +highlighters/main/main-highlighter.zsh:449> parameter_name=1 +highlighters/main/main-highlighter.zsh:451> [[ none == none ]] +highlighters/main/main-highlighter.zsh:451> zmodload -e zsh/parameter +highlighters/main/main-highlighter.zsh:452> [[ ${parameter_name} -regex-match ^${~parameter_name_pattern}$ ]] +highlighters/main/main-highlighter.zsh:453> [[ '' != *special* ]] +highlighters/main/main-highlighter.zsh:456> case array-special (*array*|*assoc*) +highlighters/main/main-highlighter.zsh:458> words=( '$1' ) +highlighters/main/main-highlighter.zsh:469> reply=( '$1' ) There are two problems here: - In terms of _zsh_highlight_main_highlighter__try_expand_parameter's pre- and postconditions, the expansion of the word «$1» (line 733) included that same word (line 469). That happened because word-to-be-expanded is passed to _zsh_highlight_main_highlighter__try_expand_parameter as its first positional parameter, and in this case the word happened to be «$1». - Furthermore, the exclusion of special parameters (line 453) false negatived. That happened because $parameter_name_pattern explicitly allows positional parameters, but ${parameters[(e)1]} expands to nothing. This will be fixed in the next commit. Not a regression from 0.7.1. |
||
---|---|---|
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.