Fast syntax hilighting for the Zsh prompt.
Go to file
2018-05-22 18:53:15 +02:00
images images: array-assign.png 2018-05-22 18:53:15 +02:00
test test: Performance test from HSMW 2018-01-05 18:37:29 +01:00
fast-highlight *-highlight: Math-mode highlighting in assignment, when $(( is used 2018-05-22 01:18:24 +02:00
fast-syntax-highlighting.plugin.zsh Revert "plugin.zsh: Ignore exit-code of Zle-widget call, go ahead and highlight" 2017-12-28 21:20:48 +01:00
LICENSE Initial commit 2017-03-26 09:31:58 +02:00
README.md Updated README.md 2018-05-22 02:07:55 +02:00

paypal

Zshell Fast Syntax Highlighting

60 commits that optimized standard zsh-syntax-highlighting to the point that it can edit 10 kB functions with zed/vared (optimizations done in history-search-multi-word). Also added:

  1. Variable highlighting

    image

  2. Colorizing of ${(a)parameter[...]} inside strings (normally only $parameter is colorized)

    image

  3. Fixed colorizing of function definition, like abc() { ... } – abc will not be red

    image

  4. Fixed colorizing of complex conditions inside [[, like [[ "$a" || "$b" ]]

    image

  5. Closing ]] and ] are highlighted (see above)

  6. Paths from $CDPATH aren't colorized unless the command is cd

Performance differencies can be observed at Asciinema recording, where 10 kB function is being edited:

asciicast

Updates (2018)

2018-05-22

Assignments are no more one-colour default-white. When used in assignment, highlighted are:

  • variables (outside strings),
  • strings (double-quoted and single-quoted),
  • math-mode (val=$(( ... ))).

sshot

2018-01-06

Math mode is highlighted  expressions (( ... )) and $(( ... )). Empty variables are colorized as red. There are 3 style names (fields of FAST_HIGHLIGHT_STYLES hash) for math-variable, number and empty variable (error): mathvar, mathnum, matherr. You can set them (like the animation below shows) to change colors.

animation

Installation

The plugin is "standalone", which means that only sourcing it is needed. So to install, unpack fast-syntax-highlighting somewhere and add

source {where-fsh-is}/fast-syntax-highlighting.plugin.zsh

to zshrc.

If using a plugin manager, then Zplugin is recommended, but you can use any other too, and also install with Oh My Zsh (by copying directory to ~/.oh-my-zsh/custom/plugins).

Zplugin

Add zplugin light zdharma/fast-syntax-highlighting to your .zshrc file. Zplugin will handle cloning the plugin for you automatically the next time you start zsh. To update issue zplugin update zdharma/fast-syntax-highlighting (update --all can also be used).

Zplugin can load f-sy-h in turbo-mode, i.e. after prompt, to speed-up .zshrc processing:

zplugin ice wait"1" # 1 second after prompt
zplugin light zdharma/fast-syntax-highlighting

Antigen

Add antigen bundle zdharma/fast-syntax-highlighting to your .zshrc file. Antigen will handle cloning the plugin for you automatically the next time you start zsh.

Oh-My-Zsh

  1. cd ~/.oh-my-zsh/custom/plugins
  2. git clone https://github.com/zdharma/fast-syntax-highlighting.git
  3. Add fast-syntax-highlighting to your plugin list

Zgen

Add zgen load zdharma/fast-syntax-highlighting to your .zshrc file in the same place you're doing your other zgen load calls in.