Compare commits
	
		
			89 Commits
		
	
	
		
			0.8.0-alph
			...
			master
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 5eb677bb0f | |
|  | e0165eaa73 | |
|  | dcc99a8649 | |
|  | db085e4661 | |
|  | 9bb3db7fd2 | |
|  | bb27265aee | |
|  | 71bd576af8 | |
|  | d59ce0fbd0 | |
|  | e82e2d042d | |
|  | 0b5b3dcc0c | |
|  | f8cd0b55b3 | |
|  | 1e82d8c83e | |
|  | dd0cf649d1 | |
|  | 65071902d3 | |
|  | 143b25eb98 | |
|  | 1386f1213e | |
|  | 754cefe018 | |
|  | 75ba3d87e3 | |
|  | b2c910a85e | |
|  | 122dc46439 | |
|  | b828f45da6 | |
|  | caa749d030 | |
|  | c5ce001467 | |
|  | 5459ebcc4e | |
|  | 2cd73fcbde | |
|  | 643717ccaf | |
|  | caeca0bf6b | |
|  | 56b4433461 | |
|  | 0ddb1a8d51 | |
|  | c10808ad5f | |
|  | b392045e6f | |
|  | c7caf57ca8 | |
|  | 1a9264bc66 | |
|  | f6a22fa842 | |
|  | 6e0e950154 | |
|  | dffe304567 | |
|  | f0e6a8ef5c | |
|  | 0e1bb14452 | |
|  | 894127b221 | |
|  | ebef4e5569 | |
|  | 993a07fc7f | |
|  | e8517244f7 | |
|  | 205bc7ea19 | |
|  | 5eb494852e | |
|  | 75c0eb0717 | |
|  | 046cb03a12 | |
|  | 1715f39a46 | |
|  | 2ebfa6a598 | |
|  | aac09942b8 | |
|  | 62c5575848 | |
|  | 4cf464f843 | |
|  | 6d5372a937 | |
|  | e9cad1493f | |
|  | 79b6e7e05f | |
|  | 3944a44ffe | |
|  | 34674d7860 | |
|  | e4d1db1e2c | |
|  | c14fcad3b0 | |
|  | 239c720dec | |
|  | 7cc6226477 | |
|  | cba4a1bc2e | |
|  | 637e1c702e | |
|  | 2d60a47cc4 | |
|  | cb33cc0081 | |
|  | 9ce3540d74 | |
|  | 59cb9a560d | |
|  | 7b863fb413 | |
|  | daf0d94bae | |
|  | c28312b9d3 | |
|  | b08d508cd8 | |
|  | 8d4c6355e6 | |
|  | 56ba7f082d | |
|  | 2cbb3fb24e | |
|  | f265ef0b9a | |
|  | d0fb0df4ff | |
|  | f665eec230 | |
|  | a868b6942e | |
|  | b5249f17ab | |
|  | d2594c1157 | |
|  | 66ae59eccc | |
|  | 1651137f5c | |
|  | d4ab7e51d2 | |
|  | 38477f2a3d | |
|  | d98622dcd0 | |
|  | 04fd6bbf53 | |
|  | 30c6e70394 | |
|  | 74a27de70d | |
|  | 85e62a8171 | |
|  | aed99f6a3e | 
|  | @ -0,0 +1,75 @@ | ||||||
|  | --- | ||||||
|  | name: Tests | ||||||
|  | on: | ||||||
|  |   push: | ||||||
|  |     paths-ignore: | ||||||
|  |       - '**.md' | ||||||
|  |       - '**.png' | ||||||
|  |   pull_request: | ||||||
|  |     paths-ignore: | ||||||
|  |       - '**.md' | ||||||
|  |       - '**.png' | ||||||
|  |   schedule: | ||||||
|  |     - cron: '29 7 * * 1' | ||||||
|  | 
 | ||||||
|  | jobs: | ||||||
|  |   test: | ||||||
|  |     runs-on: ubuntu-latest | ||||||
|  |     strategy: | ||||||
|  |       fail-fast: false | ||||||
|  |       matrix: | ||||||
|  |         version: | ||||||
|  |           - master | ||||||
|  |           - 5.9 | ||||||
|  |           - 5.8.1 | ||||||
|  |           - 5.8 | ||||||
|  |           - 5.7.1 | ||||||
|  |           - 5.7 | ||||||
|  |           - 5.6.2 | ||||||
|  |           - 5.6.1 | ||||||
|  |           - 5.6 | ||||||
|  |           - 5.5.1 | ||||||
|  |           - 5.5 | ||||||
|  |           - 5.4.2 | ||||||
|  |           - 5.4.1 | ||||||
|  |           - 5.4 | ||||||
|  |           - 5.3.1 | ||||||
|  |           - 5.3 | ||||||
|  |           - 5.2 | ||||||
|  |           - 5.1.1 | ||||||
|  |           - 5.1 | ||||||
|  |           - 5.0.8 | ||||||
|  |           - 5.0.7 | ||||||
|  |           - 5.0.6 | ||||||
|  |           - 5.0.5 | ||||||
|  |           - 5.0.4 | ||||||
|  |           - 5.0.3 | ||||||
|  |           - 5.0.2 | ||||||
|  |           - 5.0.1 | ||||||
|  |           - 5.0.0 | ||||||
|  |           - 4.3.17 | ||||||
|  |           - 4.3.16 | ||||||
|  |           - 4.3.15 | ||||||
|  |           - 4.3.14 | ||||||
|  |           - 4.3.13 | ||||||
|  |           - 4.3.12 | ||||||
|  |           - 4.3.11 | ||||||
|  |     container: | ||||||
|  |       image: ghcr.io/zsh-users/zsh:${{ matrix.version }} | ||||||
|  |     steps: | ||||||
|  |       - uses: actions/checkout@v4 | ||||||
|  |       - run: install_packages bsdmainutils make procps | ||||||
|  |       - run: make test | ||||||
|  | 
 | ||||||
|  |   notify: | ||||||
|  |     runs-on: ubuntu-latest | ||||||
|  |     needs: test | ||||||
|  |     if: failure() && (github.repository_owner == 'zsh-users') | ||||||
|  |     steps: | ||||||
|  |       - | ||||||
|  |         name: Notify IRC | ||||||
|  |         uses: Gottox/irc-message-action@v2 | ||||||
|  |         with: | ||||||
|  |           channel: '#zsh-syntax-highlighting' | ||||||
|  |           nickname: zsyh-gh-bot | ||||||
|  |           message: '${{ github.ref }} failed tests: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' | ||||||
							
								
								
									
										56
									
								
								.travis.yml
								
								
								
								
							
							
						
						
									
										56
									
								
								.travis.yml
								
								
								
								
							|  | @ -1,56 +0,0 @@ | ||||||
| language: generic |  | ||||||
| sudo: required |  | ||||||
| 
 |  | ||||||
| env: |  | ||||||
|   - ZSH=master |  | ||||||
|   - ZSH=5.8 |  | ||||||
|   - ZSH=5.7.1 |  | ||||||
|   - ZSH=5.7 |  | ||||||
|   - ZSH=5.6.2 |  | ||||||
|   - ZSH=5.6.1 |  | ||||||
|   - ZSH=5.6 |  | ||||||
|   - ZSH=5.5.1 |  | ||||||
|   - ZSH=5.5 |  | ||||||
|   - ZSH=5.4.2 |  | ||||||
|   - ZSH=5.4.1 |  | ||||||
|   - ZSH=5.4 |  | ||||||
|   - ZSH=5.3.1 |  | ||||||
|   - ZSH=5.3 |  | ||||||
|   - ZSH=5.2 |  | ||||||
|   - ZSH=5.1.1 |  | ||||||
|   - ZSH=5.1 |  | ||||||
|   - ZSH=5.0.8 |  | ||||||
|   - ZSH=5.0.7 |  | ||||||
|   - ZSH=5.0.6 |  | ||||||
|   - ZSH=5.0.5 |  | ||||||
|   - ZSH=5.0.4 |  | ||||||
|   - ZSH=5.0.3 |  | ||||||
|   - ZSH=5.0.2 |  | ||||||
|   - ZSH=5.0.1 |  | ||||||
|   - ZSH=5.0.0 |  | ||||||
|   - ZSH=4.3.17 |  | ||||||
|   - ZSH=4.3.16 |  | ||||||
|   - ZSH=4.3.15 |  | ||||||
|   - ZSH=4.3.14 |  | ||||||
|   - ZSH=4.3.13 |  | ||||||
|   - ZSH=4.3.12 |  | ||||||
|   - ZSH=4.3.11 |  | ||||||
| 
 |  | ||||||
| script: docker run -v $PWD:/work -w /work zshusers/zsh:${ZSH} /bin/sh -c 'install_packages make procps bsdmainutils && make test' |  | ||||||
| 
 |  | ||||||
| notifications: |  | ||||||
|   webhooks: |  | ||||||
|     urls: |  | ||||||
|       - https://webhooks.gitter.im/e/367e241cdea60cb2070b |  | ||||||
|     on_success: change |  | ||||||
|     on_failure: always |  | ||||||
|     on_start: never |  | ||||||
|   irc: |  | ||||||
|     channels: |  | ||||||
|       - "chat.freenode.net#zsh-syntax-highlighting" |  | ||||||
|     on_success: change |  | ||||||
|     on_failure: always |  | ||||||
|     on_start: never |  | ||||||
|     use_notice: true |  | ||||||
|     template: |  | ||||||
|       - "%{repository}/%{branch}#%{build_number}: %{message} Changes : %{compare_url} | Build : %{build_url}" |  | ||||||
|  | @ -95,5 +95,5 @@ zstyle ':completion:*:*:*:*:globbed-files' ignored-patterns {'*/',}zsh-syntax-hi | ||||||
| IRC channel | IRC channel | ||||||
| ----------- | ----------- | ||||||
| 
 | 
 | ||||||
| We're on #zsh-syntax-highlighting on freenode. | We're on #zsh-syntax-highlighting on Libera.Chat. | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										68
									
								
								INSTALL.md
								
								
								
								
							
							
						
						
									
										68
									
								
								INSTALL.md
								
								
								
								
							|  | @ -3,31 +3,67 @@ How to install | ||||||
| 
 | 
 | ||||||
| ### Using packages | ### Using packages | ||||||
| 
 | 
 | ||||||
|  | First, install the package: | ||||||
|  | 
 | ||||||
| * Arch Linux: [community/zsh-syntax-highlighting][arch-package] / [AUR/zsh-syntax-highlighting-git][AUR-package] | * Arch Linux: [community/zsh-syntax-highlighting][arch-package] / [AUR/zsh-syntax-highlighting-git][AUR-package] | ||||||
| * Debian: `zsh-syntax-highlighting` package [in `stretch`][debian-package] (or in [OBS repository][obs-repository]) | * Debian: `zsh-syntax-highlighting` package [in `stretch`][debian-package] (or in [OBS repository][obs-repository]) | ||||||
| * Fedora: [zsh-syntax-highlighting package][fedora-package-alt] in Fedora 24+ (or in [OBS repository][obs-repository]) | * Fedora: [zsh-syntax-highlighting package][fedora-package-alt] in Fedora 24+ (or in [OBS repository][obs-repository]) | ||||||
| * FreeBSD: `pkg install zsh-syntax-highlighting` (port name: [`shells/zsh-syntax-highlighting`][freebsd-port]) | * FreeBSD: `pkg install zsh-syntax-highlighting` (port name: [`shells/zsh-syntax-highlighting`][freebsd-port]) | ||||||
| * Gentoo: [mv overlay][gentoo-overlay] | * Gentoo: [app-shells/zsh-syntax-highlighting][gentoo-repository] | ||||||
| * Mac OS X / Homebrew: [brew install zsh-syntax-highlighting][brew-package] | * Mac OS X / Homebrew: `brew install zsh-syntax-highlighting` ([formula][brew-package]) | ||||||
| * Ubuntu: `zsh-syntax-highlighting` package [in Xenial][ubuntu-package] (or in [OBS repository][obs-repository]) | * NetBSD: `pkg_add zsh-syntax-highlighting` (port name: [`shells/zsh-syntax-highlighting`][netbsd-port]) | ||||||
| * RHEL / CentOS / Scientific Linux: `zsh-syntax-highlighting` package in [OBS repository][obs-repository] | * OpenBSD: `pkg_add zsh-syntax-highlighting` (port name: [`shells/zsh-syntax-highlighting`][openbsd-port]) | ||||||
| * openSUSE / SLE: `zsh-syntax-highlighting` package in [OBS repository][obs-repository] | * openSUSE / SLE: `zsh-syntax-highlighting` package in [OBS repository][obs-repository] | ||||||
|  | * RHEL / CentOS / Scientific Linux: `zsh-syntax-highlighting` package in [OBS repository][obs-repository] | ||||||
|  | * Ubuntu: `zsh-syntax-highlighting` package [in Xenial][ubuntu-package] (or in [OBS repository][obs-repository]) | ||||||
| * Void Linux: `zsh-syntax-highlighting package` [in XBPS][void-package] | * Void Linux: `zsh-syntax-highlighting package` [in XBPS][void-package] | ||||||
| 
 | 
 | ||||||
| [arch-package]: https://www.archlinux.org/packages/zsh-syntax-highlighting | [arch-package]: https://www.archlinux.org/packages/zsh-syntax-highlighting | ||||||
| [AUR-package]: https://aur.archlinux.org/packages/zsh-syntax-highlighting-git | [AUR-package]: https://aur.archlinux.org/packages/zsh-syntax-highlighting-git | ||||||
|  | [brew-package]: https://github.com/Homebrew/homebrew-core/blob/master/Formula/z/zsh-syntax-highlighting.rb | ||||||
| [debian-package]: https://packages.debian.org/zsh-syntax-highlighting | [debian-package]: https://packages.debian.org/zsh-syntax-highlighting | ||||||
| [freebsd-port]: http://www.freshports.org/textproc/zsh-syntax-highlighting/ |  | ||||||
| [gentoo-overlay]: http://gpo.zugaina.org/app-shells/zsh-syntax-highlighting |  | ||||||
| [brew-package]: https://github.com/Homebrew/homebrew-core/blob/master/Formula/zsh-syntax-highlighting.rb |  | ||||||
| [ubuntu-package]: https://launchpad.net/ubuntu/+source/zsh-syntax-highlighting |  | ||||||
| [fedora-package]: https://apps.fedoraproject.org/packages/zsh-syntax-highlighting | [fedora-package]: https://apps.fedoraproject.org/packages/zsh-syntax-highlighting | ||||||
| [fedora-package-alt]: https://bodhi.fedoraproject.org/updates/?packages=zsh-syntax-highlighting | [fedora-package-alt]: https://bodhi.fedoraproject.org/updates/?packages=zsh-syntax-highlighting | ||||||
|  | [freebsd-port]: https://www.freshports.org/textproc/zsh-syntax-highlighting/ | ||||||
|  | [gentoo-repository]: https://packages.gentoo.org/packages/app-shells/zsh-syntax-highlighting | ||||||
|  | [netbsd-port]: http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/shells/zsh-syntax-highlighting/ | ||||||
| [obs-repository]: https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-syntax-highlighting&package=zsh-syntax-highlighting | [obs-repository]: https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-syntax-highlighting&package=zsh-syntax-highlighting | ||||||
|  | [openbsd-port]: https://cvsweb.openbsd.org/ports/shells/zsh-syntax-highlighting/ | ||||||
|  | [ubuntu-package]: https://launchpad.net/ubuntu/+source/zsh-syntax-highlighting | ||||||
| [void-package]: https://github.com/void-linux/void-packages/tree/master/srcpkgs/zsh-syntax-highlighting | [void-package]: https://github.com/void-linux/void-packages/tree/master/srcpkgs/zsh-syntax-highlighting | ||||||
| 
 | 
 | ||||||
| See also [repology's cross-distro index](https://repology.org/metapackage/zsh-syntax-highlighting/versions) | See also [repology's cross-distro index](https://repology.org/metapackage/zsh-syntax-highlighting/versions) | ||||||
| 
 | 
 | ||||||
|  | Second, enable zsh-syntax-highlighting by sourcing the script. Running this command on the terminal will add the source line to the end of your .zshrc: | ||||||
|  | 
 | ||||||
|  | * On most Linux distributions (except perhaps NixOS): | ||||||
|  | 
 | ||||||
|  |     ```zsh | ||||||
|  |     echo "source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc | ||||||
|  |     ``` | ||||||
|  | 
 | ||||||
|  | * NetBSD and OpenBSD: | ||||||
|  | 
 | ||||||
|  |     ```zsh | ||||||
|  |     echo "source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc | ||||||
|  |     ``` | ||||||
|  | 
 | ||||||
|  | * Mac OS X / Homebrew: | ||||||
|  | 
 | ||||||
|  |     ```zsh | ||||||
|  |     echo "source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc | ||||||
|  |     ``` | ||||||
|  | 
 | ||||||
|  | Then restart zsh (such as by opening a new instance of your terminal emulator). | ||||||
|  | 
 | ||||||
|  |  Alternatively, add the `source` command manually **at the end** of your `.zshrc`: | ||||||
|  | 
 | ||||||
|  | * On most Linux distributions (except perhaps NixOS): | ||||||
|  | `source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh` | ||||||
|  | * NetBSD and OpenBSD: | ||||||
|  | `source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh` | ||||||
|  | 
 | ||||||
|  | Then restart zsh. | ||||||
| 
 | 
 | ||||||
| ### In your ~/.zshrc | ### In your ~/.zshrc | ||||||
| 
 | 
 | ||||||
|  | @ -71,6 +107,12 @@ This list is incomplete as there are too many | ||||||
| Add `antigen bundle zsh-users/zsh-syntax-highlighting` as the last bundle in | Add `antigen bundle zsh-users/zsh-syntax-highlighting` as the last bundle in | ||||||
| your `.zshrc`. | your `.zshrc`. | ||||||
| 
 | 
 | ||||||
|  | #### [Fig](https://fig.io) | ||||||
|  | 
 | ||||||
|  | Click the `Install Plugin` button on the [Fig plugin page][fig-plugin]. | ||||||
|  | 
 | ||||||
|  | [fig-plugin]: https://fig.io/plugins/other/zsh-syntax-highlighting | ||||||
|  | 
 | ||||||
| #### [Oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) | #### [Oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) | ||||||
| 
 | 
 | ||||||
| 1. Clone this repository in oh-my-zsh's plugins directory: | 1. Clone this repository in oh-my-zsh's plugins directory: | ||||||
|  | @ -98,15 +140,15 @@ Zsh-syntax-highlighting is included with Prezto. See the | ||||||
| 
 | 
 | ||||||
| Add `zgen load zsh-users/zsh-syntax-highlighting` to the end of your `.zshrc`. | Add `zgen load zsh-users/zsh-syntax-highlighting` to the end of your `.zshrc`. | ||||||
| 
 | 
 | ||||||
|  | #### [zinit](https://github.com/zdharma-continuum/zinit) | ||||||
|  | 
 | ||||||
|  | Add `zinit light zsh-users/zsh-syntax-highlighting` to the end of your | ||||||
|  | `.zshrc`. | ||||||
|  | 
 | ||||||
| #### [zplug](https://github.com/zplug/zplug) | #### [zplug](https://github.com/zplug/zplug) | ||||||
| 
 | 
 | ||||||
| Add `zplug "zsh-users/zsh-syntax-highlighting", defer:2` to your `.zshrc`. | Add `zplug "zsh-users/zsh-syntax-highlighting", defer:2` to your `.zshrc`. | ||||||
| 
 | 
 | ||||||
| #### [zplugin](https://github.com/psprint/zplugin) |  | ||||||
| 
 |  | ||||||
| Add `zplugin load zsh-users/zsh-syntax-highlighting` to the end of your |  | ||||||
| `.zshrc`. |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| ### System-wide installation | ### System-wide installation | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										30
									
								
								README.md
								
								
								
								
							
							
						
						
									
										30
									
								
								README.md
								
								
								
								
							|  | @ -1,12 +1,12 @@ | ||||||
| zsh-syntax-highlighting [![Build Status][build-status-image]][build-status-travis] | zsh-syntax-highlighting [![Build Status][build-status-image]][build-status] | ||||||
| ======================= | ======================= | ||||||
| 
 | 
 | ||||||
| **[Fish shell][fish]-like syntax highlighting for [Zsh][zsh].** | **[Fish shell][fish]-like syntax highlighting for [Zsh][zsh].** | ||||||
| 
 | 
 | ||||||
| *Requirements: zsh 4.3.11+.* | *Requirements: zsh 4.3.11+.* | ||||||
| 
 | 
 | ||||||
| [fish]: http://www.fishshell.com/ | [fish]: https://fishshell.com/ | ||||||
| [zsh]: http://www.zsh.org/ | [zsh]: https://www.zsh.org/ | ||||||
| 
 | 
 | ||||||
| This package provides syntax highlighting for the shell zsh.  It enables | This package provides syntax highlighting for the shell zsh.  It enables | ||||||
| highlighting of commands whilst they are typed at a zsh prompt into an | highlighting of commands whilst they are typed at a zsh prompt into an | ||||||
|  | @ -44,11 +44,23 @@ FAQ | ||||||
| 
 | 
 | ||||||
| ### Why must `zsh-syntax-highlighting.zsh` be sourced at the end of the `.zshrc` file? | ### 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 | zsh-syntax-highlighting works by hooking into the Zsh Line Editor (ZLE) and | ||||||
| custom widgets have been created (i.e., after all `zle -N` calls and after | computing syntax highlighting for the command-line buffer as it stands at the | ||||||
| running `compinit`).  Widgets created later will work, but will not update the | time z-sy-h's hook is invoked. | ||||||
|  | 
 | ||||||
|  | In zsh 5.2 and older, | ||||||
|  | `zsh-syntax-highlighting.zsh` hooks into ZLE by wrapping ZLE widgets.  It must | ||||||
|  | be sourced after all custom widgets have been created (i.e., after all `zle -N` | ||||||
|  | calls and after running `compinit`) in order to be able to wrap all of them. | ||||||
|  | Widgets created after z-sy-h is sourced will work, but will not update the | ||||||
| syntax highlighting. | syntax highlighting. | ||||||
| 
 | 
 | ||||||
|  | In zsh newer than 5.8 (not including 5.8 itself), | ||||||
|  | zsh-syntax-highlighting uses the `add-zle-hook-widget` facility to install | ||||||
|  | a `zle-line-pre-redraw` hook.  Hooks are run in order of registration, | ||||||
|  | therefore, z-sy-h must be sourced (and register its hook) after anything else | ||||||
|  | that adds hooks that modify the command-line buffer. | ||||||
|  | 
 | ||||||
| ### Does syntax highlighting work during incremental history search? | ### Does syntax highlighting work during incremental history search? | ||||||
| 
 | 
 | ||||||
| Highlighting the command line during an incremental history search (by default bound to | Highlighting the command line during an incremental history search (by default bound to | ||||||
|  | @ -61,7 +73,7 @@ enough information to allow computing the highlighting correctly.) | ||||||
| 
 | 
 | ||||||
| See issues [#288][i288] and [#415][i415] for details. | See issues [#288][i288] and [#415][i415] for details. | ||||||
| 
 | 
 | ||||||
| [zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | [zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | ||||||
| [i288]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/288 | [i288]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/288 | ||||||
| [i415]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/415 | [i415]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/415 | ||||||
| 
 | 
 | ||||||
|  | @ -81,5 +93,5 @@ Syntax highlighting is done by pluggable highlighter scripts.  See the | ||||||
| [documentation on highlighters](docs/highlighters.md) for details and | [documentation on highlighters](docs/highlighters.md) for details and | ||||||
| configuration settings. | configuration settings. | ||||||
| 
 | 
 | ||||||
| [build-status-image]: https://travis-ci.org/zsh-users/zsh-syntax-highlighting.svg?branch=master | [build-status]: https://github.com/zsh-users/zsh-syntax-highlighting/actions | ||||||
| [build-status-travis]: https://travis-ci.org/zsh-users/zsh-syntax-highlighting | [build-status-image]: https://github.com/zsh-users/zsh-syntax-highlighting/workflows/Tests/badge.svg | ||||||
|  |  | ||||||
							
								
								
									
										121
									
								
								changelog.md
								
								
								
								
							
							
						
						
									
										121
									
								
								changelog.md
								
								
								
								
							|  | @ -1,3 +1,96 @@ | ||||||
|  | # Changes in HEAD | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | - Highlight `&>` `>&|` `>&!` `&>|` and `&>!` as redirection. | ||||||
|  |   [#942] | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # Changes in 0.8.0 | ||||||
|  | 
 | ||||||
|  | This is a stable bugfix and feature release.  Major new features and changes include: | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | ## Changes fixed as part of the switch to zle-line-pre-redraw | ||||||
|  | 
 | ||||||
|  | The changes in this section were fixed by switching to a `zle-line-pre-redraw`-based | ||||||
|  | implementation. | ||||||
|  | 
 | ||||||
|  | Note: The new implementation will only be used on future zsh releases, | ||||||
|  | numbered 5.8.1.1 and newer, due to interoperability issues with other plugins | ||||||
|  | (issues #418 and #579).  The underlying zsh feature has been available since | ||||||
|  | zsh 5.3. | ||||||
|  | 
 | ||||||
|  | Whilst under development, the new implementation was known as the | ||||||
|  | "feature/redrawhook" topic branch. | ||||||
|  | 
 | ||||||
|  | - Fixed: Highlighting not triggered after popping a buffer from the buffer stack | ||||||
|  |   (using the `push-line` widget, default binding: `M-q`) | ||||||
|  |   [#40] | ||||||
|  | 
 | ||||||
|  | - Fixed: Invoking completion when there were no matches removed highlighting | ||||||
|  |   [#90, #470] | ||||||
|  | 
 | ||||||
|  | - Fixed: Two successive deletes followed by a yank only yanked the latest | ||||||
|  |   delete, rather than both of them | ||||||
|  |   [#150, #151, #160; cf. #183] | ||||||
|  | 
 | ||||||
|  | - Presumed fixed: Completing `$(xsel)` results in an error message from `xsel`, | ||||||
|  |   with pre-2017 versions of `xsel`.  (For 2017 vintage and newer, see the issue | ||||||
|  |   for details.) | ||||||
|  |   [#154] | ||||||
|  | 
 | ||||||
|  | - Fixed: When the standard `bracketed-paste-magic` widget is in use, pastes were slow | ||||||
|  |   [#295] | ||||||
|  | 
 | ||||||
|  | - Fixed: No way to prevent a widget from being wrapped | ||||||
|  |   [#324] | ||||||
|  | 
 | ||||||
|  | - Fixed: No highlighting while cycling menu completion | ||||||
|  |   [#375] | ||||||
|  | 
 | ||||||
|  | - Fixed: Does not coexist with the `IGNORE_EOF` option | ||||||
|  |   [#377] | ||||||
|  | 
 | ||||||
|  | - Fixed: The `undefined-key` widget was wrapped | ||||||
|  |   [#421] | ||||||
|  | 
 | ||||||
|  | - Fixed: Does not coexist with the standard `surround` family of widgets | ||||||
|  |   [#520] | ||||||
|  | 
 | ||||||
|  | - Fixed: First completed filename doesn't get `path` highlighting | ||||||
|  |   [#632] | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | ## Other changes | ||||||
|  | 
 | ||||||
|  | - Add issue #712 to the previous release's changelog (hereinafter). | ||||||
|  | 
 | ||||||
|  | - Fix highlighting when using an alias twice inside another alias | ||||||
|  |   [#769, #775] | ||||||
|  | 
 | ||||||
|  | - Remove lint warning for `env` followed by a pipe | ||||||
|  |   [#797] | ||||||
|  | 
 | ||||||
|  | - Recognize `proxychains` as a precommand | ||||||
|  |   [#814, #914] | ||||||
|  | 
 | ||||||
|  | - Honor shwordsplit when expanding parameters | ||||||
|  |   [#687, #818] | ||||||
|  | 
 | ||||||
|  | - Skip highlighting when keys are still pending in more cases | ||||||
|  |   [#835] | ||||||
|  | 
 | ||||||
|  | - Recognize `grc` as a precommand | ||||||
|  | 
 | ||||||
|  | - Recognize `torsocks` and `torift` as precommands | ||||||
|  |   [#898] | ||||||
|  | 
 | ||||||
|  | - Recognize `cpulimit` as a precommand | ||||||
|  |   [#897] | ||||||
|  | 
 | ||||||
|  | - Recognize `ktrace` as a precommand | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| # Changes in 0.8.0-alpha1-pre-redrawhook | # Changes in 0.8.0-alpha1-pre-redrawhook | ||||||
| 
 | 
 | ||||||
| ## Notice about an improbable-but-not-impossible forward incompatibility | ## Notice about an improbable-but-not-impossible forward incompatibility | ||||||
|  | @ -16,6 +109,25 @@ added to zsh at z-sy-h's initiative.  The new feature is used in the fix | ||||||
| to issue #418. | to issue #418. | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | ## Incompatible changes: | ||||||
|  | 
 | ||||||
|  | - An unsuccessful completion (a <kbd>⮀ Tab</kbd> press that doesn't change the | ||||||
|  |   command line) no longer causes highlighting to be lost.  Visual feedback can | ||||||
|  |   alternatively be achieved by setting the `format` zstyle under the `warnings` | ||||||
|  |   tag, for example, | ||||||
|  | 
 | ||||||
|  |         zstyle ':completion:*:warnings' format '%F{red}No matches%f' | ||||||
|  | 
 | ||||||
|  |     Refer to the [description of the `format` style in `zshcompsys(1)`] | ||||||
|  |     [zshcompsys-Standard-Styles-format]. | ||||||
|  | 
 | ||||||
|  |     (#90, part of #245 (feature/redrawhook)) | ||||||
|  | 
 | ||||||
|  | [zshcompsys-Standard-Styles]: https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Standard-Styles | ||||||
|  | [zshcompsys-Standard-Styles-format]: https://zsh.sourceforge.io/Doc/Release/Completion-System.html#index-format_002c-completion-style | ||||||
|  |    | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| ## Other changes: | ## Other changes: | ||||||
| 
 | 
 | ||||||
| - Document `$ZSH_HIGHLIGHT_MAXLENGTH`. | - Document `$ZSH_HIGHLIGHT_MAXLENGTH`. | ||||||
|  | @ -90,6 +202,8 @@ to issue #418. | ||||||
| 
 | 
 | ||||||
| - Recognize `env` as a precommand (e.g., `env FOO=bar ls`) | - Recognize `env` as a precommand (e.g., `env FOO=bar ls`) | ||||||
| 
 | 
 | ||||||
|  | - Recognize `ionice` as a precommand | ||||||
|  | 
 | ||||||
| - Recognize `strace` as a precommand | - Recognize `strace` as a precommand | ||||||
| 
 | 
 | ||||||
| - Fix an error message on stderr before every prompt when the `WARN_NESTED_VAR` zsh option is set: | - Fix an error message on stderr before every prompt when the `WARN_NESTED_VAR` zsh option is set: | ||||||
|  | @ -114,6 +228,9 @@ to issue #418. | ||||||
| 
 | 
 | ||||||
| - Improve performance of the `brackets` highlighter. | - Improve performance of the `brackets` highlighter. | ||||||
| 
 | 
 | ||||||
|  | - Fix highlighting of pre-command redirections (e.g., the `$fn` in `<$fn cat`) | ||||||
|  |   [#712] | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| # Changes in version 0.7.1 | # Changes in version 0.7.1 | ||||||
| 
 | 
 | ||||||
|  | @ -208,7 +325,7 @@ This is a stable release, featuring bugfixes and minor improvements. | ||||||
| - The `isearch` and `suffix` [`$zle_highlight` settings][zshzle-Character-Highlighting]. | - The `isearch` and `suffix` [`$zle_highlight` settings][zshzle-Character-Highlighting]. | ||||||
|   (79e4d3d12405, 15db71abd0cc, b56ee542d619; requires zsh 5.3 for `$ISEARCHMATCH_ACTIVE` / `$SUFFIX_ACTIVE` support) |   (79e4d3d12405, 15db71abd0cc, b56ee542d619; requires zsh 5.3 for `$ISEARCHMATCH_ACTIVE` / `$SUFFIX_ACTIVE` support) | ||||||
| 
 | 
 | ||||||
| [zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | [zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | ||||||
| 
 | 
 | ||||||
| - Possible history expansions in double-quoted strings. | - Possible history expansions in double-quoted strings. | ||||||
|   (76ea9e1df316) |   (76ea9e1df316) | ||||||
|  | @ -654,7 +771,7 @@ in this area. | ||||||
| 
 | 
 | ||||||
| ## Developer-visible changes: | ## Developer-visible changes: | ||||||
| 
 | 
 | ||||||
| - Test harness converted to [TAP](http://testanything.org/tap-specification.html) format | - Test harness converted to [TAP](https://testanything.org/tap-specification.html) format | ||||||
|   (d99aa58aaaef, et seq) |   (d99aa58aaaef, et seq) | ||||||
| 
 | 
 | ||||||
| - Run each test in a separate subprocess, isolating them from each other | - Run each test in a separate subprocess, isolating them from each other | ||||||
|  |  | ||||||
|  | @ -3,19 +3,21 @@ zsh-syntax-highlighting / highlighters | ||||||
| 
 | 
 | ||||||
| Syntax highlighting is done by pluggable highlighters: | Syntax highlighting is done by pluggable highlighters: | ||||||
| 
 | 
 | ||||||
| * `main` - the base highlighter, and the only one [active by default][1]. | * `main` - the base highlighter, and the only one [active by default][main]. | ||||||
| * `brackets` - [matches brackets][2] and parenthesis. | * `brackets` - [matches brackets][brackets] and parenthesis. | ||||||
| * `pattern` - matches [user-defined patterns][3]. | * `pattern` - matches [user-defined patterns][pattern]. | ||||||
| * `cursor` - matches [the cursor position][4]. | * `regexp` - matches [user-defined regular expressions][regexp]. | ||||||
| * `root` - highlights the whole command line [if the current user is root][5]. | * `cursor` - matches [the cursor position][cursor]. | ||||||
| * `line` - applied to [the whole command line][6]. | * `root` - highlights the whole command line [if the current user is root][root]. | ||||||
|  | * `line` - applied to [the whole command line][line]. | ||||||
| 
 | 
 | ||||||
| [1]: highlighters/main.md | [main]: highlighters/main.md | ||||||
| [2]: highlighters/brackets.md | [brackets]: highlighters/brackets.md | ||||||
| [3]: highlighters/pattern.md | [pattern]: highlighters/pattern.md | ||||||
| [4]: highlighters/cursor.md | [regexp]: highlighters/regexp.md | ||||||
| [5]: highlighters/root.md | [cursor]: highlighters/cursor.md | ||||||
| [6]: highlighters/line.md | [root]: highlighters/root.md | ||||||
|  | [line]: highlighters/line.md | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| Highlighter-independent settings | Highlighter-independent settings | ||||||
|  | @ -25,10 +27,10 @@ By default, all command lines are highlighted.  However, it is possible to | ||||||
| prevent command lines longer than a fixed number of characters from being | prevent command lines longer than a fixed number of characters from being | ||||||
| highlighted by setting the variable `${ZSH_HIGHLIGHT_MAXLENGTH}` to the maximum | highlighted by setting the variable `${ZSH_HIGHLIGHT_MAXLENGTH}` to the maximum | ||||||
| length (in characters) of command lines to be highlighter.  This is useful when | length (in characters) of command lines to be highlighter.  This is useful when | ||||||
| editing very long comand lines (for example, with the [`fned`][fned] utility | editing very long command lines (for example, with the [`fned`][fned] utility | ||||||
| function).  Example: | function).  Example: | ||||||
| 
 | 
 | ||||||
| [fned]: http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#index-zed | [fned]: https://zsh.sourceforge.io/Doc/Release/User-Contributions.html#index-zed | ||||||
| 
 | 
 | ||||||
| ```zsh | ```zsh | ||||||
| ZSH_HIGHLIGHT_MAXLENGTH=512 | ZSH_HIGHLIGHT_MAXLENGTH=512 | ||||||
|  | @ -38,16 +40,14 @@ ZSH_HIGHLIGHT_MAXLENGTH=512 | ||||||
| How to activate highlighters | How to activate highlighters | ||||||
| ---------------------------- | ---------------------------- | ||||||
| 
 | 
 | ||||||
| To activate an highlighter, add it to the `ZSH_HIGHLIGHT_HIGHLIGHTERS` array in | To activate an highlighter, add it to the `ZSH_HIGHLIGHT_HIGHLIGHTERS` array. | ||||||
| `~/.zshrc`, for example: | By default `ZSH_HIGHLIGHT_HIGHLIGHTERS` is `(main)`. For example to activate | ||||||
|  | `brackets`, `pattern`, and `cursor` highlighters, in `~/.zshrc` do: | ||||||
| 
 | 
 | ||||||
| ```zsh | ```zsh | ||||||
| ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor) | ZSH_HIGHLIGHT_HIGHLIGHTERS+=(brackets pattern cursor) | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| By default, `$ZSH_HIGHLIGHT_HIGHLIGHTERS` is unset and only the `main` |  | ||||||
| highlighter is active. |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| How to tweak highlighters | How to tweak highlighters | ||||||
| ------------------------- | ------------------------- | ||||||
|  | @ -59,7 +59,7 @@ same as the syntax of "types of highlighting" of the zsh builtin | ||||||
| `$zle_highlight` array, which is documented in [the `zshzle(1)` manual | `$zle_highlight` array, which is documented in [the `zshzle(1)` manual | ||||||
| page][zshzle-Character-Highlighting]. | page][zshzle-Character-Highlighting]. | ||||||
| 
 | 
 | ||||||
| [zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | [zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | ||||||
| 
 | 
 | ||||||
| Some highlighters support additional configuration parameters; see each | Some highlighters support additional configuration parameters; see each | ||||||
| highlighter's documentation for details and examples. | highlighter's documentation for details and examples. | ||||||
|  |  | ||||||
|  | @ -28,4 +28,4 @@ The syntax for values is the same as the syntax of "types of highlighting" of | ||||||
| the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` | the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` | ||||||
| manual page][zshzle-Character-Highlighting]. | manual page][zshzle-Character-Highlighting]. | ||||||
| 
 | 
 | ||||||
| [zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | [zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | ||||||
|  |  | ||||||
|  | @ -21,4 +21,4 @@ The syntax for values is the same as the syntax of "types of highlighting" of | ||||||
| the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` | the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` | ||||||
| manual page][zshzle-Character-Highlighting]. | manual page][zshzle-Character-Highlighting]. | ||||||
| 
 | 
 | ||||||
| [zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | [zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | ||||||
|  |  | ||||||
|  | @ -21,4 +21,4 @@ The syntax for values is the same as the syntax of "types of highlighting" of | ||||||
| the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` | the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` | ||||||
| manual page][zshzle-Character-Highlighting]. | manual page][zshzle-Character-Highlighting]. | ||||||
| 
 | 
 | ||||||
| [zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | [zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | ||||||
|  |  | ||||||
|  | @ -116,6 +116,6 @@ of that (new) kind will be highlighted by the style `arg0_$kind`, | ||||||
| where `$kind` is the output of `type -w` on the new kind of command word.  If that | where `$kind` is the output of `type -w` on the new kind of command word.  If that | ||||||
| style is not defined, then the style `arg0` will be used instead. | style is not defined, then the style `arg0` will be used instead. | ||||||
| 
 | 
 | ||||||
| [zshmisc-Simple-Commands-And-Pipelines]: http://zsh.sourceforge.net/Doc/Release/Shell-Grammar.html#Simple-Commands-_0026-Pipelines | [zshmisc-Simple-Commands-And-Pipelines]: https://zsh.sourceforge.io/Doc/Release/Shell-Grammar.html#Simple-Commands-_0026-Pipelines | ||||||
| 
 | 
 | ||||||
| [zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | [zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | ||||||
|  |  | ||||||
|  | @ -21,4 +21,4 @@ The syntax for values is the same as the syntax of "types of highlighting" of | ||||||
| the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` | the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` | ||||||
| manual page][zshzle-Character-Highlighting]. | manual page][zshzle-Character-Highlighting]. | ||||||
| 
 | 
 | ||||||
| [zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | [zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | ||||||
|  |  | ||||||
|  | @ -12,11 +12,44 @@ To use this highlighter, associate regular expressions with styles in the | ||||||
| 
 | 
 | ||||||
| ```zsh | ```zsh | ||||||
| typeset -A ZSH_HIGHLIGHT_REGEXP | typeset -A ZSH_HIGHLIGHT_REGEXP | ||||||
| ZSH_HIGHLIGHT_REGEXP+=('\bsudo\b' fg=123,bold) | ZSH_HIGHLIGHT_REGEXP+=('^rm .*' fg=red,bold) | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| This will highlight "sudo" only as a complete word, i.e., "sudo cmd", but not | This will highlight lines that start with a call to the `rm` command. | ||||||
| "sudoedit" | 
 | ||||||
|  | The regular expressions flavour used is [PCRE][pcresyntax] when the | ||||||
|  | `RE_MATCH_PCRE` option is set and POSIX Extended Regular Expressions (ERE), | ||||||
|  | as implemented by the platform's C library, otherwise.  For details on the | ||||||
|  | latter, see [the `zsh/regex` module's documentation][MAN_ZSH_REGEX] and the | ||||||
|  | `regcomp(3)` and `re_format(7)` manual pages on your system. | ||||||
|  | 
 | ||||||
|  | For instance, to highlight `sudo` only as a complete word, i.e., `sudo cmd`, | ||||||
|  | but not `sudoedit`, one might use: | ||||||
|  | 
 | ||||||
|  | * When the `RE_MATCH_PCRE` is set: | ||||||
|  | 
 | ||||||
|  |     ```zsh | ||||||
|  |     typeset -A ZSH_HIGHLIGHT_REGEXP | ||||||
|  |     ZSH_HIGHLIGHT_REGEXP+=('\bsudo\b' fg=123,bold) | ||||||
|  |     ``` | ||||||
|  | 
 | ||||||
|  | * When the `RE_MATCH_PCRE` is unset, on platforms with GNU `libc` (e.g., many GNU/Linux distributions): | ||||||
|  | 
 | ||||||
|  |     ```zsh | ||||||
|  |     typeset -A ZSH_HIGHLIGHT_REGEXP | ||||||
|  |     ZSH_HIGHLIGHT_REGEXP+=('\<sudo\>' fg=123,bold) | ||||||
|  |     ``` | ||||||
|  | 
 | ||||||
|  | * When the `RE_MATCH_PCRE` is unset, on BSD-based platforms (e.g., macOS): | ||||||
|  | 
 | ||||||
|  |     ```zsh | ||||||
|  |     typeset -A ZSH_HIGHLIGHT_REGEXP | ||||||
|  |     ZSH_HIGHLIGHT_REGEXP+=('[[:<:]]sudo[[:>:]]' fg=123,bold) | ||||||
|  |     ``` | ||||||
|  | 
 | ||||||
|  | Note, however, that PCRE and POSIX ERE have a large common subset: | ||||||
|  | for instance, the regular expressions `[abc]`, `a*`, and `(a|b)` have the same | ||||||
|  | meaning in both flavours. | ||||||
| 
 | 
 | ||||||
| The syntax for values is the same as the syntax of "types of highlighting" of | The syntax for values is the same as the syntax of "types of highlighting" of | ||||||
| the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` | the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` | ||||||
|  | @ -25,6 +58,8 @@ manual page][zshzle-Character-Highlighting]. | ||||||
| See also: [regular expressions tutorial][perlretut], zsh regexp operator `=~` | See also: [regular expressions tutorial][perlretut], zsh regexp operator `=~` | ||||||
| in [the `zshmisc(1)` manual page][zshmisc-Conditional-Expressions] | in [the `zshmisc(1)` manual page][zshmisc-Conditional-Expressions] | ||||||
| 
 | 
 | ||||||
| [zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | [zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | ||||||
| [perlretut]: http://perldoc.perl.org/perlretut.html | [perlretut]: https://perldoc.perl.org/perlretut | ||||||
| [zshmisc-Conditional-Expressions]: http://zsh.sourceforge.net/Doc/Release/Conditional-Expressions.html#Conditional-Expressions | [zshmisc-Conditional-Expressions]: https://zsh.sourceforge.io/Doc/Release/Conditional-Expressions.html#Conditional-Expressions | ||||||
|  | [MAN_ZSH_REGEX]: https://zsh.sourceforge.io/Doc/Release/Zsh-Modules.html#The-zsh_002fregex-Module | ||||||
|  | [pcresyntax]: https://www.pcre.org/original/doc/html/pcresyntax.html | ||||||
|  |  | ||||||
|  | @ -22,4 +22,4 @@ The syntax for values is the same as the syntax of "types of highlighting" of | ||||||
| the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` | the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` | ||||||
| manual page][zshzle-Character-Highlighting]. | manual page][zshzle-Character-Highlighting]. | ||||||
| 
 | 
 | ||||||
| [zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | [zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting | ||||||
|  |  | ||||||
|  | @ -76,7 +76,7 @@ _zsh_highlight_main_add_region_highlight() { | ||||||
|   integer start=$1 end=$2 |   integer start=$1 end=$2 | ||||||
|   shift 2 |   shift 2 | ||||||
| 
 | 
 | ||||||
|   if (( in_alias )); then |   if (( $#in_alias )); then | ||||||
|     [[ $1 == unknown-token ]] && alias_style=unknown-token |     [[ $1 == unknown-token ]] && alias_style=unknown-token | ||||||
|     return |     return | ||||||
|   fi |   fi | ||||||
|  | @ -254,10 +254,9 @@ _zsh_highlight_main__is_runnable() { | ||||||
| _zsh_highlight_main__is_redirection() { | _zsh_highlight_main__is_redirection() { | ||||||
|   # A redirection operator token: |   # A redirection operator token: | ||||||
|   # - starts with an optional single-digit number; |   # - starts with an optional single-digit number; | ||||||
|   # - then, has a '<' or '>' character; |   # - is one of the tokens listed in zshmisc(1) | ||||||
|   # - is not a process substitution [<(...) or >(...)]. |   # - however (z) normalizes ! to | | ||||||
|   # - is not a numeric glob <-> |   [[ ${1#[0-9]} == (\<|\<\>|(\>|\>\>)(|\|)|\<\<(|-)|\<\<\<|\<\&|\&\<|(\>|\>\>)\&(|\|)|\&(\>|\>\>)(|\||\!)) ]] | ||||||
|   [[ $1 == (<0-9>|)(\<|\>)* ]] && [[ $1 != (\<|\>)$'\x28'* ]] && [[ $1 != *'<'*'-'*'>'* ]] |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| # Resolve alias. | # Resolve alias. | ||||||
|  | @ -349,6 +348,7 @@ _zsh_highlight_highlighter_main_paint() | ||||||
|     'noglob' '' |     'noglob' '' | ||||||
|     # 'time' and 'nocorrect' shouldn't be added here; they're reserved words, not precommands. |     # 'time' and 'nocorrect' shouldn't be added here; they're reserved words, not precommands. | ||||||
| 
 | 
 | ||||||
|  |     # miscellaneous commands | ||||||
|     'doas' aCu:Lns # as of OpenBSD's doas(1) dated September 4, 2016 |     'doas' aCu:Lns # as of OpenBSD's doas(1) dated September 4, 2016 | ||||||
|     'nice' n: # as of current POSIX spec |     'nice' n: # as of current POSIX spec | ||||||
|     'pkexec' '' # doesn't take short options; immune to #121 because it's usually not passed --option flags |     'pkexec' '' # doesn't take short options; immune to #121 because it's usually not passed --option flags | ||||||
|  | @ -362,21 +362,21 @@ _zsh_highlight_highlighter_main_paint() | ||||||
|     'env' u:i |     'env' u:i | ||||||
|     'ionice' cn:t:pPu # util-linux 2.33.1-0.1 |     'ionice' cn:t:pPu # util-linux 2.33.1-0.1 | ||||||
|     'strace' IbeaosXPpEuOS:ACdfhikqrtTvVxyDc # strace 4.26-0.2 |     'strace' IbeaosXPpEuOS:ACdfhikqrtTvVxyDc # strace 4.26-0.2 | ||||||
| 
 |     'proxychains' f:q # proxychains 4.4.0 | ||||||
|     # As of OpenSSH 8.1p1 |     'torsocks' idq:upaP # Torsocks 2.3.0 | ||||||
|     'ssh-agent' aEPt:csDd:k |     'torify' idq:upaP # Torsocks 2.3.0 | ||||||
|     # suckless-tools v44 |     'ssh-agent' aEPt:csDd:k # As of OpenSSH 8.1p1 | ||||||
|     # Argumentless flags that can't be followed by a command: -v |     'tabbed' gnprtTuU:cdfhs:v # suckless-tools v44 | ||||||
|     'tabbed' gnprtTuU:cdfhs |     'chronic' :ev # moreutils 0.62-1 | ||||||
| 
 |     'ifne' :n # moreutils 0.62-1 | ||||||
|     # moreutils 0.62-1 |     'grc' :se # grc - a "generic colouriser" (that's their spelling, not mine) | ||||||
|     'chronic' :ev |     'cpulimit' elp:ivz # cpulimit 0.2 | ||||||
|     'ifne' :n |     'ktrace' fgpt:aBCcdiT | ||||||
| 
 |  | ||||||
|   ) |   ) | ||||||
|   # Commands that would need to skip one positional argument: |   # Commands that would need to skip one positional argument: | ||||||
|   #    flock |   #    flock | ||||||
|   #    ssh |   #    ssh | ||||||
|  |   #    _wanted (skip two) | ||||||
| 
 | 
 | ||||||
|   if [[ $zsyh_user_options[ignorebraces] == on || ${zsyh_user_options[ignoreclosebraces]:-off} == on ]]; then |   if [[ $zsyh_user_options[ignorebraces] == on || ${zsyh_user_options[ignoreclosebraces]:-off} == on ]]; then | ||||||
|     local right_brace_is_recognised_everywhere=false |     local right_brace_is_recognised_everywhere=false | ||||||
|  | @ -476,7 +476,11 @@ _zsh_highlight_main_highlighter__try_expand_parameter() | ||||||
|             ;; |             ;; | ||||||
|           (*) |           (*) | ||||||
|             # scalar, presumably |             # scalar, presumably | ||||||
|             words=( ${(P)MATCH} ) |             if [[ $zsyh_user_options[shwordsplit] == on ]]; then | ||||||
|  |               words=( ${(P)=MATCH} ) | ||||||
|  |             else | ||||||
|  |               words=( ${(P)MATCH} ) | ||||||
|  |             fi | ||||||
|             ;; |             ;; | ||||||
|         esac |         esac | ||||||
|         reply=( "${words[@]}" ) |         reply=( "${words[@]}" ) | ||||||
|  | @ -498,17 +502,18 @@ _zsh_highlight_main_highlighter__try_expand_parameter() | ||||||
| _zsh_highlight_main_highlighter_highlight_list() | _zsh_highlight_main_highlighter_highlight_list() | ||||||
| { | { | ||||||
|   integer start_pos end_pos=0 buf_offset=$1 has_end=$3 |   integer start_pos end_pos=0 buf_offset=$1 has_end=$3 | ||||||
|   # alias_style is the style to apply to an alias once in_alias=0 |   # alias_style is the style to apply to an alias once $#in_alias == 0 | ||||||
|   #     Usually 'alias' but set to 'unknown-token' if any word expanded from |   #     Usually 'alias' but set to 'unknown-token' if any word expanded from | ||||||
|   #     the alias would be highlighted as unknown-token |   #     the alias would be highlighted as unknown-token | ||||||
|   # param_style is analogous for parameter expansions |   # param_style is analogous for parameter expansions | ||||||
|   local alias_style param_style last_arg arg buf=$4 highlight_glob=true saw_assignment=false style |   local alias_style param_style last_arg arg buf=$4 highlight_glob=true saw_assignment=false style | ||||||
|   local in_array_assignment=false # true between 'a=(' and the matching ')' |   local in_array_assignment=false # true between 'a=(' and the matching ')' | ||||||
|   # in_alias is equal to the number of shifts needed until arg=args[1] pops an |   # in_alias is an array of integers with each element equal to the number | ||||||
|   #     arg from BUFFER and not added by an alias. |   #     of shifts needed until arg=args[1] pops an arg from the next level up | ||||||
|  |   #     alias or from BUFFER. | ||||||
|   # in_param is analogous for parameter expansions |   # in_param is analogous for parameter expansions | ||||||
|   integer in_alias=0 in_param=0 len=$#buf |   integer in_param=0 len=$#buf | ||||||
|   local -a match mbegin mend list_highlights |   local -a in_alias match mbegin mend list_highlights | ||||||
|   # seen_alias is a map of aliases already seen to avoid loops like alias a=b b=a |   # seen_alias is a map of aliases already seen to avoid loops like alias a=b b=a | ||||||
|   local -A seen_alias |   local -A seen_alias | ||||||
|   # Pattern for parameter names |   # Pattern for parameter names | ||||||
|  | @ -596,12 +601,23 @@ _zsh_highlight_main_highlighter_highlight_list() | ||||||
|     last_arg=$arg |     last_arg=$arg | ||||||
|     arg=$args[1] |     arg=$args[1] | ||||||
|     shift args |     shift args | ||||||
|     if (( in_alias )); then |     if (( $#in_alias )); then | ||||||
|       (( in_alias-- )) |       (( in_alias[1]-- )) | ||||||
|       if (( in_alias == 0 )); then |       # Remove leading 0 entries | ||||||
|  |       in_alias=($in_alias[$in_alias[(i)<1->],-1]) | ||||||
|  |       if (( $#in_alias == 0 )); then | ||||||
|         seen_alias=() |         seen_alias=() | ||||||
|         # start_pos and end_pos are of the alias (previous $arg) here |         # start_pos and end_pos are of the alias (previous $arg) here | ||||||
|         _zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style |         _zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style | ||||||
|  |       else | ||||||
|  |         # We can't unset keys that contain special characters (] \ and some others). | ||||||
|  |         # More details: https://www.zsh.org/workers/43269 | ||||||
|  |         (){ | ||||||
|  |           local alias_name | ||||||
|  |           for alias_name in ${(k)seen_alias[(R)<$#in_alias->]}; do | ||||||
|  |             seen_alias=("${(@kv)seen_alias[(I)^$alias_name]}") | ||||||
|  |           done | ||||||
|  |         } | ||||||
|       fi |       fi | ||||||
|     fi |     fi | ||||||
|     if (( in_param )); then |     if (( in_param )); then | ||||||
|  | @ -637,9 +653,9 @@ _zsh_highlight_main_highlighter_highlight_list() | ||||||
|       fi |       fi | ||||||
|     fi |     fi | ||||||
| 
 | 
 | ||||||
|     if (( in_alias == 0 && in_param == 0 )); then |     if (( $#in_alias == 0 && in_param == 0 )); then | ||||||
|       # Compute the new $start_pos and $end_pos, skipping over whitespace in $buf. |       # Compute the new $start_pos and $end_pos, skipping over whitespace in $buf. | ||||||
|       [[ "$proc_buf" = (#b)(#s)(([ $'\t']|[\\]$'\n')#)(?|)* ]] |       [[ "$proc_buf" = (#b)(#s)(''([ $'\t']|[\\]$'\n')#)(?|)* ]] | ||||||
|       # The first, outer parenthesis |       # The first, outer parenthesis | ||||||
|       integer offset="${#match[1]}" |       integer offset="${#match[1]}" | ||||||
|       (( start_pos = end_pos + offset )) |       (( start_pos = end_pos + offset )) | ||||||
|  | @ -693,11 +709,10 @@ _zsh_highlight_main_highlighter_highlight_list() | ||||||
|       if [[ $res == "alias" ]]; then |       if [[ $res == "alias" ]]; then | ||||||
|         # Mark insane aliases as unknown-token (cf. #263). |         # Mark insane aliases as unknown-token (cf. #263). | ||||||
|         if [[ $arg == ?*=* ]]; then |         if [[ $arg == ?*=* ]]; then | ||||||
|           (( in_alias == 0 )) && in_alias=1 |  | ||||||
|           _zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token |           _zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token | ||||||
|           continue |           continue | ||||||
|         fi |         fi | ||||||
|         seen_alias[$arg]=1 |         seen_alias[$arg]=$#in_alias | ||||||
|         _zsh_highlight_main__resolve_alias $arg |         _zsh_highlight_main__resolve_alias $arg | ||||||
|         local -a alias_args |         local -a alias_args | ||||||
|         # Elision is desired in case alias x='' |         # Elision is desired in case alias x='' | ||||||
|  | @ -707,15 +722,15 @@ _zsh_highlight_main_highlighter_highlight_list() | ||||||
|           alias_args=(${(z)REPLY}) |           alias_args=(${(z)REPLY}) | ||||||
|         fi |         fi | ||||||
|         args=( $alias_args $args ) |         args=( $alias_args $args ) | ||||||
|         if (( in_alias == 0 )); then |         if (( $#in_alias == 0 )); then | ||||||
|           alias_style=alias |           alias_style=alias | ||||||
|           # Add one because we will in_alias-- on the next loop iteration so |  | ||||||
|           # this iteration should be considered in in_alias as well |  | ||||||
|           (( in_alias += $#alias_args + 1 )) |  | ||||||
|         else |         else | ||||||
|           # This arg is already included in the count, so no need to + 1. |           # Transfer the count of this arg to the new element about to be appended. | ||||||
|           (( in_alias += $#alias_args )) |           (( in_alias[1]-- )) | ||||||
|         fi |         fi | ||||||
|  |         # Add one because we will in_alias[1]-- on the next loop iteration so | ||||||
|  |         # this iteration should be considered in in_alias as well | ||||||
|  |         in_alias=( $(($#alias_args + 1)) $in_alias ) | ||||||
|         (( in_redirection++ )) # Stall this arg |         (( in_redirection++ )) # Stall this arg | ||||||
|         continue |         continue | ||||||
|       else |       else | ||||||
|  | @ -728,7 +743,7 @@ _zsh_highlight_main_highlighter_highlight_list() | ||||||
|     # Analyse the current word. |     # Analyse the current word. | ||||||
|     if _zsh_highlight_main__is_redirection $arg ; then |     if _zsh_highlight_main__is_redirection $arg ; then | ||||||
|       if (( in_redirection == 1 )); then |       if (( in_redirection == 1 )); then | ||||||
|         # Two consecuive redirection operators is an error. |         # Two consecutive redirection operators is an error. | ||||||
|         _zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token |         _zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token | ||||||
|       else |       else | ||||||
|         in_redirection=2 |         in_redirection=2 | ||||||
|  | @ -854,7 +869,7 @@ _zsh_highlight_main_highlighter_highlight_list() | ||||||
|         style=commandseparator |         style=commandseparator | ||||||
|       elif [[ $this_word == *':start:'* ]] && [[ $arg == $'\n' ]]; then |       elif [[ $this_word == *':start:'* ]] && [[ $arg == $'\n' ]]; then | ||||||
|         style=commandseparator |         style=commandseparator | ||||||
|       elif [[ $this_word == *':start:'* ]] && [[ $arg == ';' ]] && (( in_alias )); then |       elif [[ $this_word == *':start:'* ]] && [[ $arg == ';' ]] && (( $#in_alias )); then | ||||||
|         style=commandseparator  |         style=commandseparator  | ||||||
|       else |       else | ||||||
|         # Empty commands (semicolon follows nothing) are valid syntax. |         # Empty commands (semicolon follows nothing) are valid syntax. | ||||||
|  | @ -879,6 +894,14 @@ _zsh_highlight_main_highlighter_highlight_list() | ||||||
|         next_word=':start:' |         next_word=':start:' | ||||||
|         highlight_glob=true |         highlight_glob=true | ||||||
|         saw_assignment=false |         saw_assignment=false | ||||||
|  |         (){ | ||||||
|  |           local alias_name | ||||||
|  |           for alias_name in ${(k)seen_alias[(R)<$#in_alias->]}; do | ||||||
|  |             # We can't unset keys that contain special characters (] \ and some others). | ||||||
|  |             # More details: https://www.zsh.org/workers/43269 | ||||||
|  |             seen_alias=("${(@kv)seen_alias[(I)^$alias_name]}") | ||||||
|  |           done | ||||||
|  |         } | ||||||
|         if [[ $arg != '|' && $arg != '|&' ]]; then |         if [[ $arg != '|' && $arg != '|&' ]]; then | ||||||
|           next_word+=':start_of_pipeline:' |           next_word+=':start_of_pipeline:' | ||||||
|         fi |         fi | ||||||
|  | @ -902,8 +925,8 @@ _zsh_highlight_main_highlighter_highlight_list() | ||||||
|         next_word=${next_word//:regular:/} |         next_word=${next_word//:regular:/} | ||||||
|         next_word+=':sudo_opt:' |         next_word+=':sudo_opt:' | ||||||
|         next_word+=':start:' |         next_word+=':start:' | ||||||
|         if [[ $arg == 'exec' ]]; then |         if [[ $arg == 'exec' || $arg == 'env' ]]; then | ||||||
|           # To allow "exec 2>&1;" where there's no command word |           # To allow "exec 2>&1;" and "env | grep" where there's no command word | ||||||
|           next_word+=':regular:' |           next_word+=':regular:' | ||||||
|         fi |         fi | ||||||
|       else |       else | ||||||
|  | @ -1146,7 +1169,7 @@ _zsh_highlight_main_highlighter_highlight_list() | ||||||
|     fi |     fi | ||||||
|     _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style |     _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style | ||||||
|   done |   done | ||||||
|   (( in_alias == 1 )) && in_alias=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style |   (( $#in_alias )) && in_alias=() _zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style | ||||||
|   (( in_param == 1 )) && in_param=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $param_style |   (( in_param == 1 )) && in_param=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $param_style | ||||||
|   [[ "$proc_buf" = (#b)(#s)(([[:space:]]|\\$'\n')#) ]] |   [[ "$proc_buf" = (#b)(#s)(([[:space:]]|\\$'\n')#) ]] | ||||||
|   REPLY=$(( end_pos + ${#match[1]} - 1 )) |   REPLY=$(( end_pos + ${#match[1]} - 1 )) | ||||||
|  | @ -1257,7 +1280,7 @@ _zsh_highlight_main_highlighter_check_path() | ||||||
| 
 | 
 | ||||||
|   # If this word ends the buffer, check if it's the prefix of a valid path. |   # If this word ends the buffer, check if it's the prefix of a valid path. | ||||||
|   if (( has_end && (len == end_pos) )) && |   if (( has_end && (len == end_pos) )) && | ||||||
|      (( ! in_alias )) && |      (( ! $#in_alias )) && | ||||||
|      [[ $WIDGET != zle-line-finish ]]; then |      [[ $WIDGET != zle-line-finish ]]; then | ||||||
|     # TODO: When we've dropped support for pre-5.0.6 zsh, use the *(Y1) glob qualifier here. |     # TODO: When we've dropped support for pre-5.0.6 zsh, use the *(Y1) glob qualifier here. | ||||||
|     local -a tmp |     local -a tmp | ||||||
|  |  | ||||||
|  | @ -0,0 +1,41 @@ | ||||||
|  | #!/usr/bin/env zsh | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # Copyright (c) 2021 zsh-syntax-highlighting contributors | ||||||
|  | # All rights reserved. | ||||||
|  | # | ||||||
|  | # Redistribution and use in source and binary forms, with or without modification, are permitted | ||||||
|  | # provided that the following conditions are met: | ||||||
|  | # | ||||||
|  | #  * Redistributions of source code must retain the above copyright notice, this list of conditions | ||||||
|  | #    and the following disclaimer. | ||||||
|  | #  * Redistributions in binary form must reproduce the above copyright notice, this list of | ||||||
|  | #    conditions and the following disclaimer in the documentation and/or other materials provided | ||||||
|  | #    with the distribution. | ||||||
|  | #  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors | ||||||
|  | #    may be used to endorse or promote products derived from this software without specific prior | ||||||
|  | #    written permission. | ||||||
|  | # | ||||||
|  | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR | ||||||
|  | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||||||
|  | # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||||||
|  | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||||
|  | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||||
|  | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||||||
|  | # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||||||
|  | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- | ||||||
|  | # vim: ft=zsh sw=2 ts=2 et | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | 
 | ||||||
|  | # Have to use cat here as it must be a command that exists. | ||||||
|  | # Otherwise, the test would fail with the first token being recognized | ||||||
|  | # as an "unknown-token". | ||||||
|  | alias ]=cat | ||||||
|  | 
 | ||||||
|  | BUFFER='] /' | ||||||
|  | 
 | ||||||
|  | expected_region_highlight=( | ||||||
|  |   '1 1 alias' # ] | ||||||
|  |   '3 3 path' # / | ||||||
|  | ) | ||||||
|  | @ -0,0 +1,39 @@ | ||||||
|  | #!/usr/bin/env zsh | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # Copyright (c) 2020 zsh-syntax-highlighting contributors | ||||||
|  | # All rights reserved. | ||||||
|  | # | ||||||
|  | # Redistribution and use in source and binary forms, with or without modification, are permitted | ||||||
|  | # provided that the following conditions are met: | ||||||
|  | # | ||||||
|  | #  * Redistributions of source code must retain the above copyright notice, this list of conditions | ||||||
|  | #    and the following disclaimer. | ||||||
|  | #  * Redistributions in binary form must reproduce the above copyright notice, this list of | ||||||
|  | #    conditions and the following disclaimer in the documentation and/or other materials provided | ||||||
|  | #    with the distribution. | ||||||
|  | #  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors | ||||||
|  | #    may be used to endorse or promote products derived from this software without specific prior | ||||||
|  | #    written permission. | ||||||
|  | # | ||||||
|  | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR | ||||||
|  | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||||||
|  | # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||||||
|  | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||||
|  | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||||
|  | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||||||
|  | # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||||||
|  | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- | ||||||
|  | # vim: ft=zsh sw=2 ts=2 et | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | 
 | ||||||
|  | alias a=: b='a | a' | ||||||
|  | 
 | ||||||
|  | BUFFER='b | b' | ||||||
|  | 
 | ||||||
|  | expected_region_highlight=( | ||||||
|  |   '1 1 alias' # b | ||||||
|  |   '3 3 commandseparator' # | | ||||||
|  |   '5 5 alias' # b | ||||||
|  | ) | ||||||
|  | @ -0,0 +1,39 @@ | ||||||
|  | #!/usr/bin/env zsh | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # Copyright (c) 2020 zsh-syntax-highlighting contributors | ||||||
|  | # All rights reserved. | ||||||
|  | # | ||||||
|  | # Redistribution and use in source and binary forms, with or without modification, are permitted | ||||||
|  | # provided that the following conditions are met: | ||||||
|  | # | ||||||
|  | #  * Redistributions of source code must retain the above copyright notice, this list of conditions | ||||||
|  | #    and the following disclaimer. | ||||||
|  | #  * Redistributions in binary form must reproduce the above copyright notice, this list of | ||||||
|  | #    conditions and the following disclaimer in the documentation and/or other materials provided | ||||||
|  | #    with the distribution. | ||||||
|  | #  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors | ||||||
|  | #    may be used to endorse or promote products derived from this software without specific prior | ||||||
|  | #    written permission. | ||||||
|  | # | ||||||
|  | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR | ||||||
|  | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||||||
|  | # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||||||
|  | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||||
|  | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||||
|  | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||||||
|  | # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||||||
|  | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- | ||||||
|  | # vim: ft=zsh sw=2 ts=2 et | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | 
 | ||||||
|  | alias a=: b='a && a' | ||||||
|  | 
 | ||||||
|  | BUFFER='b && b' | ||||||
|  | 
 | ||||||
|  | expected_region_highlight=( | ||||||
|  |   '1 1 alias' # b | ||||||
|  |   '3 4 commandseparator' # && | ||||||
|  |   '6 6 alias' # b | ||||||
|  | ) | ||||||
|  | @ -0,0 +1,39 @@ | ||||||
|  | #!/usr/bin/env zsh | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # Copyright (c) 2020 zsh-syntax-highlighting contributors | ||||||
|  | # All rights reserved. | ||||||
|  | # | ||||||
|  | # Redistribution and use in source and binary forms, with or without modification, are permitted | ||||||
|  | # provided that the following conditions are met: | ||||||
|  | # | ||||||
|  | #  * Redistributions of source code must retain the above copyright notice, this list of conditions | ||||||
|  | #    and the following disclaimer. | ||||||
|  | #  * Redistributions in binary form must reproduce the above copyright notice, this list of | ||||||
|  | #    conditions and the following disclaimer in the documentation and/or other materials provided | ||||||
|  | #    with the distribution. | ||||||
|  | #  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors | ||||||
|  | #    may be used to endorse or promote products derived from this software without specific prior | ||||||
|  | #    written permission. | ||||||
|  | # | ||||||
|  | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR | ||||||
|  | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||||||
|  | # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||||||
|  | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||||
|  | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||||
|  | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||||||
|  | # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||||||
|  | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- | ||||||
|  | # vim: ft=zsh sw=2 ts=2 et | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | 
 | ||||||
|  | alias a=: b='a; a' | ||||||
|  | 
 | ||||||
|  | BUFFER='b; b' | ||||||
|  | 
 | ||||||
|  | expected_region_highlight=( | ||||||
|  |   '1 1 alias' # b | ||||||
|  |   '2 2 commandseparator' # ; | ||||||
|  |   '4 4 alias' # b | ||||||
|  | ) | ||||||
|  | @ -0,0 +1,42 @@ | ||||||
|  | #!/usr/bin/env zsh | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # Copyright (c) 2020 zsh-syntax-highlighting contributors | ||||||
|  | # All rights reserved. | ||||||
|  | # | ||||||
|  | # Redistribution and use in source and binary forms, with or without modification, are permitted | ||||||
|  | # provided that the following conditions are met: | ||||||
|  | # | ||||||
|  | #  * Redistributions of source code must retain the above copyright notice, this list of conditions | ||||||
|  | #    and the following disclaimer. | ||||||
|  | #  * Redistributions in binary form must reproduce the above copyright notice, this list of | ||||||
|  | #    conditions and the following disclaimer in the documentation and/or other materials provided | ||||||
|  | #    with the distribution. | ||||||
|  | #  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors | ||||||
|  | #    may be used to endorse or promote products derived from this software without specific prior | ||||||
|  | #    written permission. | ||||||
|  | # | ||||||
|  | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR | ||||||
|  | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||||||
|  | # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||||||
|  | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||||
|  | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||||
|  | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||||||
|  | # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||||||
|  | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- | ||||||
|  | # vim: ft=zsh sw=2 ts=2 et | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | 
 | ||||||
|  | alias a=: b='a $(a)' | ||||||
|  | 
 | ||||||
|  | BUFFER='b $(b)' | ||||||
|  | 
 | ||||||
|  | expected_region_highlight=( | ||||||
|  |   '1 1 alias' # b | ||||||
|  |   '3 6 default' # $(b) | ||||||
|  |   '3 6 command-substitution-unquoted' # $(b) | ||||||
|  |   '3 4 command-substitution-delimiter-unquoted' # $( | ||||||
|  |   '5 5 alias' # b | ||||||
|  |   '6 6 command-substitution-delimiter-unquoted' # ) | ||||||
|  | ) | ||||||
|  | @ -0,0 +1,43 @@ | ||||||
|  | #!/usr/bin/env zsh | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # Copyright (c) 2020 zsh-syntax-highlighting contributors | ||||||
|  | # All rights reserved. | ||||||
|  | # | ||||||
|  | # Redistribution and use in source and binary forms, with or without modification, are permitted | ||||||
|  | # provided that the following conditions are met: | ||||||
|  | # | ||||||
|  | #  * Redistributions of source code must retain the above copyright notice, this list of conditions | ||||||
|  | #    and the following disclaimer. | ||||||
|  | #  * Redistributions in binary form must reproduce the above copyright notice, this list of | ||||||
|  | #    conditions and the following disclaimer in the documentation and/or other materials provided | ||||||
|  | #    with the distribution. | ||||||
|  | #  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors | ||||||
|  | #    may be used to endorse or promote products derived from this software without specific prior | ||||||
|  | #    written permission. | ||||||
|  | # | ||||||
|  | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR | ||||||
|  | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||||||
|  | # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||||||
|  | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||||
|  | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||||
|  | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||||||
|  | # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||||||
|  | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- | ||||||
|  | # vim: ft=zsh sw=2 ts=2 et | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | 
 | ||||||
|  | alias a=: b='a < <(a)' | ||||||
|  | 
 | ||||||
|  | BUFFER='b < <(b)' | ||||||
|  | 
 | ||||||
|  | expected_region_highlight=( | ||||||
|  |   '1 1 alias' # b | ||||||
|  |   '3 3 redirection' # < | ||||||
|  |   '5 8 default' # <(b) | ||||||
|  |   '5 8 process-substitution' # <(b) | ||||||
|  |   '5 6 process-substitution-delimiter' # <( | ||||||
|  |   '7 7 alias' # b | ||||||
|  |   '8 8 process-substitution-delimiter' # ) | ||||||
|  | ) | ||||||
|  | @ -0,0 +1,37 @@ | ||||||
|  | #!/usr/bin/env zsh | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # Copyright (c) 2020 zsh-syntax-highlighting contributors | ||||||
|  | # All rights reserved. | ||||||
|  | # | ||||||
|  | # Redistribution and use in source and binary forms, with or without modification, are permitted | ||||||
|  | # provided that the following conditions are met: | ||||||
|  | # | ||||||
|  | #  * Redistributions of source code must retain the above copyright notice, this list of conditions | ||||||
|  | #    and the following disclaimer. | ||||||
|  | #  * Redistributions in binary form must reproduce the above copyright notice, this list of | ||||||
|  | #    conditions and the following disclaimer in the documentation and/or other materials provided | ||||||
|  | #    with the distribution. | ||||||
|  | #  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors | ||||||
|  | #    may be used to endorse or promote products derived from this software without specific prior | ||||||
|  | #    written permission. | ||||||
|  | # | ||||||
|  | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR | ||||||
|  | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||||||
|  | # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||||||
|  | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||||
|  | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||||
|  | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||||||
|  | # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||||||
|  | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- | ||||||
|  | # vim: ft=zsh sw=2 ts=2 et | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | 
 | ||||||
|  | alias cat='cat | cat' | ||||||
|  | 
 | ||||||
|  | BUFFER='cat' | ||||||
|  | 
 | ||||||
|  | expected_region_highlight=( | ||||||
|  |   '1 3 alias' # cat | ||||||
|  | ) | ||||||
|  | @ -0,0 +1,38 @@ | ||||||
|  | #!/usr/bin/env zsh | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # Copyright (c) 2022 zsh-syntax-highlighting contributors | ||||||
|  | # All rights reserved. | ||||||
|  | # | ||||||
|  | # Redistribution and use in source and binary forms, with or without modification, are permitted | ||||||
|  | # provided that the following conditions are met: | ||||||
|  | # | ||||||
|  | #  * Redistributions of source code must retain the above copyright notice, this list of conditions | ||||||
|  | #    and the following disclaimer. | ||||||
|  | #  * Redistributions in binary form must reproduce the above copyright notice, this list of | ||||||
|  | #    conditions and the following disclaimer in the documentation and/or other materials provided | ||||||
|  | #    with the distribution. | ||||||
|  | #  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors | ||||||
|  | #    may be used to endorse or promote products derived from this software without specific prior | ||||||
|  | #    written permission. | ||||||
|  | # | ||||||
|  | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR | ||||||
|  | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||||||
|  | # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||||||
|  | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||||
|  | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||||
|  | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||||||
|  | # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||||||
|  | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- | ||||||
|  | # vim: ft=zsh sw=2 ts=2 et | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | 
 | ||||||
|  | BUFFER=$'{ a=42 }' | ||||||
|  | 
 | ||||||
|  | expected_region_highlight=( | ||||||
|  |   '1 1 reserved-word' # { | ||||||
|  |   '3 6 assign' # a=42 | ||||||
|  |   '5 6 default' # 42 | ||||||
|  |   '8 8 reserved word "issue #854"' # } | ||||||
|  | ) | ||||||
|  | @ -27,7 +27,7 @@ | ||||||
| # vim: ft=zsh sw=2 ts=2 et | # vim: ft=zsh sw=2 ts=2 et | ||||||
| # ------------------------------------------------------------------------------------------------- | # ------------------------------------------------------------------------------------------------- | ||||||
| 
 | 
 | ||||||
| BUFFER='ps aux | grep java | sort | uniq | tail | head' | BUFFER='id bob | grep java | sort | uniq | tail | head' | ||||||
| 
 | 
 | ||||||
| expected_region_highlight=( | expected_region_highlight=( | ||||||
|   "1  2  command" # ps |   "1  2  command" # ps | ||||||
|  |  | ||||||
|  | @ -0,0 +1,38 @@ | ||||||
|  | #!/usr/bin/env zsh | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # Copyright (c) 2021 zsh-syntax-highlighting contributors | ||||||
|  | # All rights reserved. | ||||||
|  | # | ||||||
|  | # Redistribution and use in source and binary forms, with or without modification, are permitted | ||||||
|  | # provided that the following conditions are met: | ||||||
|  | # | ||||||
|  | #  * Redistributions of source code must retain the above copyright notice, this list of conditions | ||||||
|  | #    and the following disclaimer. | ||||||
|  | #  * Redistributions in binary form must reproduce the above copyright notice, this list of | ||||||
|  | #    conditions and the following disclaimer in the documentation and/or other materials provided | ||||||
|  | #    with the distribution. | ||||||
|  | #  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors | ||||||
|  | #    may be used to endorse or promote products derived from this software without specific prior | ||||||
|  | #    written permission. | ||||||
|  | # | ||||||
|  | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR | ||||||
|  | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||||||
|  | # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||||||
|  | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||||
|  | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||||
|  | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||||||
|  | # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||||||
|  | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- | ||||||
|  | # vim: ft=zsh sw=2 ts=2 et | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | 
 | ||||||
|  | BUFFER=$'env | grep $needle' | ||||||
|  | 
 | ||||||
|  | expected_region_highlight=( | ||||||
|  |   '1 3 precommand' # env | ||||||
|  |   '5 5 commandseparator' # | | ||||||
|  |   '7 10 command' # grep | ||||||
|  |   '12 18 default' # $needle | ||||||
|  | ) | ||||||
|  | @ -36,5 +36,5 @@ ed() { command ed "$@" } | ||||||
| BUFFER=$'$EDITOR' | BUFFER=$'$EDITOR' | ||||||
| 
 | 
 | ||||||
| expected_region_highlight=( | expected_region_highlight=( | ||||||
|   '1 7 function "issue #687"' # $EDITOR |   '1 7 function' # $EDITOR | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | @ -0,0 +1,38 @@ | ||||||
|  | #!/usr/bin/env zsh | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # Copyright (c) 2021 zsh-syntax-highlighting contributors | ||||||
|  | # All rights reserved. | ||||||
|  | # | ||||||
|  | # Redistribution and use in source and binary forms, with or without modification, are permitted | ||||||
|  | # provided that the following conditions are met: | ||||||
|  | # | ||||||
|  | #  * Redistributions of source code must retain the above copyright notice, this list of conditions | ||||||
|  | #    and the following disclaimer. | ||||||
|  | #  * Redistributions in binary form must reproduce the above copyright notice, this list of | ||||||
|  | #    conditions and the following disclaimer in the documentation and/or other materials provided | ||||||
|  | #    with the distribution. | ||||||
|  | #  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors | ||||||
|  | #    may be used to endorse or promote products derived from this software without specific prior | ||||||
|  | #    written permission. | ||||||
|  | # | ||||||
|  | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR | ||||||
|  | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||||||
|  | # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||||||
|  | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||||
|  | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||||
|  | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||||||
|  | # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||||||
|  | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- | ||||||
|  | # vim: ft=zsh sw=2 ts=2 et | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | 
 | ||||||
|  | setopt sh_word_split | ||||||
|  | local foo='echo foo' | ||||||
|  | 
 | ||||||
|  | BUFFER='$foo' | ||||||
|  | 
 | ||||||
|  | expected_region_highlight=( | ||||||
|  |   '1 4 builtin' # $foo | ||||||
|  | ) | ||||||
|  | @ -28,8 +28,12 @@ | ||||||
| # vim: ft=zsh sw=2 ts=2 et | # vim: ft=zsh sw=2 ts=2 et | ||||||
| # ------------------------------------------------------------------------------------------------- | # ------------------------------------------------------------------------------------------------- | ||||||
| 
 | 
 | ||||||
| alias -g x=y | if type global_alias >/dev/null; then | ||||||
| local s=x |   skip_test="Test is written on the assumption that 'global_alias' is not a valid command name, but that assumption does not hold" | ||||||
|  |   return 0 | ||||||
|  | fi | ||||||
|  | alias -g global_alias=y | ||||||
|  | local s=global_alias | ||||||
| 
 | 
 | ||||||
| BUFFER=$'$s' | BUFFER=$'$s' | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -29,11 +29,12 @@ | ||||||
| # ------------------------------------------------------------------------------------------------- | # ------------------------------------------------------------------------------------------------- | ||||||
| 
 | 
 | ||||||
| hash sudo=false | hash sudo=false | ||||||
|  | touch foo | ||||||
| 
 | 
 | ||||||
| BUFFER='sudo -e /etc/passwd' | BUFFER='sudo -e ./foo' | ||||||
| 
 | 
 | ||||||
| expected_region_highlight=( | expected_region_highlight=( | ||||||
|   '1 4 precommand' # sudo |   '1 4 precommand' # sudo | ||||||
|   '6 7 single-hyphen-option' # -e |   '6 7 single-hyphen-option' # -e | ||||||
|   '9 19 path' # /etc/passwd |   '9 13 path' # ./foo | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | @ -0,0 +1,95 @@ | ||||||
|  | #!/usr/bin/env zsh | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # Copyright (c) 2024 zsh-syntax-highlighting contributors | ||||||
|  | # All rights reserved. | ||||||
|  | # | ||||||
|  | # Redistribution and use in source and binary forms, with or without modification, are permitted | ||||||
|  | # provided that the following conditions are met: | ||||||
|  | # | ||||||
|  | #  * Redistributions of source code must retain the above copyright notice, this list of conditions | ||||||
|  | #    and the following disclaimer. | ||||||
|  | #  * Redistributions in binary form must reproduce the above copyright notice, this list of | ||||||
|  | #    conditions and the following disclaimer in the documentation and/or other materials provided | ||||||
|  | #    with the distribution. | ||||||
|  | #  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors | ||||||
|  | #    may be used to endorse or promote products derived from this software without specific prior | ||||||
|  | #    written permission. | ||||||
|  | # | ||||||
|  | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR | ||||||
|  | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||||||
|  | # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||||||
|  | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||||
|  | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||||
|  | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||||||
|  | # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||||||
|  | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- | ||||||
|  | # vim: ft=zsh sw=2 ts=2 et | ||||||
|  | # ------------------------------------------------------------------------------------------------- | ||||||
|  | 
 | ||||||
|  | BUFFER=$': <foo 9<foo <>foo 9<>foo >foo 9>foo >|foo >\!foo >>foo >>|foo >>\!foo <<<foo <&9 >&9 <&- >&- <&p >&p >&foo &>foo >&|foo >&\!foo &>|foo &>\!foo >>&foo &>>foo >>&|foo >>&\!foo &>>|foo &>>\!foo' | ||||||
|  | 
 | ||||||
|  | expected_region_highlight=( | ||||||
|  |   '1 1 builtin' # : | ||||||
|  |   '3 3 redirection' # < | ||||||
|  |   '4 6 default' # foo | ||||||
|  |   '8 9 redirection' # 9< | ||||||
|  |   '10 12 default' # foo | ||||||
|  |   '14 15 redirection' # <> | ||||||
|  |   '16 18 default' # foo | ||||||
|  |   '20 22 redirection' # 9<> | ||||||
|  |   '23 25 default' # foo | ||||||
|  |   '27 27 redirection' # > | ||||||
|  |   '28 30 default' # foo | ||||||
|  |   '32 33 redirection' # 9> | ||||||
|  |   '34 36 default' # foo | ||||||
|  |   '38 39 redirection' # >| | ||||||
|  |   '40 42 default' # foo | ||||||
|  |   '44 45 redirection' # >\! | ||||||
|  |   '46 48 default' # foo | ||||||
|  |   '50 51 redirection' # >> | ||||||
|  |   '52 54 default' # foo | ||||||
|  |   '56 58 redirection' # >>| | ||||||
|  |   '59 61 default' # foo | ||||||
|  |   '63 65 redirection' # >>\! | ||||||
|  |   '66 68 default' # foo | ||||||
|  |   '70 72 redirection' # <<< | ||||||
|  |   '73 75 default' # foo | ||||||
|  |   '77 78 redirection' # <& | ||||||
|  |   '79 79 numeric-fd' # 9 | ||||||
|  |   '81 82 redirection' # >& | ||||||
|  |   '83 83 numeric-fd' # 9 | ||||||
|  |   '85 86 redirection' # <& | ||||||
|  |   '87 87 redirection' # - | ||||||
|  |   '89 90 redirection' # >& | ||||||
|  |   '91 91 redirection' # - | ||||||
|  |   '93 94 redirection' # <& | ||||||
|  |   '95 95 redirection' # p | ||||||
|  |   '97 98 redirection' # >& | ||||||
|  |   '99 99 redirection' # p | ||||||
|  |   '101 102 redirection' # >& | ||||||
|  |   '103 105 default' # foo | ||||||
|  |   '107 108 redirection' # &> | ||||||
|  |   '109 111 default' # foo | ||||||
|  |   '113 115 redirection' # >&| | ||||||
|  |   '116 118 default' # foo | ||||||
|  |   '120 122 redirection' # >&\! | ||||||
|  |   '123 125 default' # foo | ||||||
|  |   '127 129 redirection' # &>| | ||||||
|  |   '130 132 default' # foo | ||||||
|  |   '134 136 redirection' # &>\! | ||||||
|  |   '137 139 default' # foo | ||||||
|  |   '141 143 redirection' # >>& | ||||||
|  |   '144 146 default' # foo | ||||||
|  |   '148 150 redirection' # &>> | ||||||
|  |   '151 153 default' # foo | ||||||
|  |   '155 158 redirection' # >>&| | ||||||
|  |   '159 161 default' # foo | ||||||
|  |   '163 166 redirection' # >>&\! | ||||||
|  |   '167 169 default' # foo | ||||||
|  |   '171 174 redirection' # &>>| | ||||||
|  |   '175 177 default' # foo | ||||||
|  |   '179 182 redirection' # &>>\! | ||||||
|  |   '183 185 default' # foo | ||||||
|  | ) | ||||||
|  | @ -27,7 +27,7 @@ | ||||||
| # vim: ft=zsh sw=2 ts=2 et | # vim: ft=zsh sw=2 ts=2 et | ||||||
| # ------------------------------------------------------------------------------------------------- | # ------------------------------------------------------------------------------------------------- | ||||||
| 
 | 
 | ||||||
| BUFFER='ps aux | grep java' | BUFFER='id bob | grep java' | ||||||
| 
 | 
 | ||||||
| expected_region_highlight=( | expected_region_highlight=( | ||||||
|   "1  2  command" # ps |   "1  2  command" # ps | ||||||
|  |  | ||||||
|  | @ -1,11 +1,12 @@ | ||||||
| # Release procedure (for developers): | # Release procedure (for developers): | ||||||
| 
 | 
 | ||||||
|  | - Ensure every `is-at-least` invocation passes a stable zsh release's version number as the first argument | ||||||
| - For minor (A.B.0) releases: | - For minor (A.B.0) releases: | ||||||
|   - Check whether the release uses any not-yet-released zsh features |   - Check whether the release uses any not-yet-released zsh features | ||||||
| - Check open issues and outstanding pull requests | - Check open issues and outstanding pull requests | ||||||
| - Confirm `make test` passes | - Confirm `make test` passes | ||||||
|   - check with multiple zsh versions |   - check with multiple zsh versions | ||||||
|     (easiest to check travis: https://travis-ci.org/zsh-users/zsh-syntax-highlighting/) |     (easiest to check GitHub Actions: https://github.com/zsh-users/zsh-syntax-highlighting/actions) | ||||||
| - Update changelog.md | - Update changelog.md | ||||||
|   `tig --abbrev=12  --abbrev-commit 0.4.1..upstream/master` |   `tig --abbrev=12  --abbrev-commit 0.4.1..upstream/master` | ||||||
| - Make sure there are no local commits and that `git status` is clean; | - Make sure there are no local commits and that `git status` is clean; | ||||||
|  |  | ||||||
|  | @ -104,7 +104,7 @@ By default, the results of all tests will be printed; to show only "interesting" | ||||||
| results (tests that failed but were expected to succeed, or vice-versa), run | results (tests that failed but were expected to succeed, or vice-versa), run | ||||||
| `make quiet-test` (or `make test QUIET=y`). | `make quiet-test` (or `make test QUIET=y`). | ||||||
| 
 | 
 | ||||||
| [TAP]: http://testanything.org/ | [TAP]: https://testanything.org/ | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| Performance test | Performance test | ||||||
|  |  | ||||||
|  | @ -31,6 +31,9 @@ | ||||||
| emulate -LR zsh | emulate -LR zsh | ||||||
| setopt localoptions extendedglob | setopt localoptions extendedglob | ||||||
| 
 | 
 | ||||||
|  | # Required for add-zle-hook-widget. | ||||||
|  | zmodload zsh/zle | ||||||
|  | 
 | ||||||
| # Argument parsing. | # Argument parsing. | ||||||
| if (( $# * $# - 7 * $# + 12 )) || [[ $1 == -* ]]; then | if (( $# * $# - 7 * $# + 12 )) || [[ $1 == -* ]]; then | ||||||
|   print -r -- >&2 "$0: usage: $0 BUFFER HIGHLIGHTER BASENAME [PREAMBLE]" |   print -r -- >&2 "$0: usage: $0 BUFFER HIGHLIGHTER BASENAME [PREAMBLE]" | ||||||
|  |  | ||||||
|  | @ -31,6 +31,9 @@ | ||||||
| 
 | 
 | ||||||
| setopt NO_UNSET WARN_CREATE_GLOBAL | setopt NO_UNSET WARN_CREATE_GLOBAL | ||||||
| 
 | 
 | ||||||
|  | # Required for add-zle-hook-widget. | ||||||
|  | zmodload zsh/zle | ||||||
|  | 
 | ||||||
| local -r root=${0:h:h} | local -r root=${0:h:h} | ||||||
| local -a anon_argv; anon_argv=("$@") | local -a anon_argv; anon_argv=("$@") | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -29,6 +29,9 @@ | ||||||
| # ------------------------------------------------------------------------------------------------- | # ------------------------------------------------------------------------------------------------- | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | # Required for add-zle-hook-widget. | ||||||
|  | zmodload zsh/zle | ||||||
|  | 
 | ||||||
| # Check an highlighter was given as argument. | # Check an highlighter was given as argument. | ||||||
| [[ -n "$1" ]] || { | [[ -n "$1" ]] || { | ||||||
|   echo >&2 "Bail out! You must provide the name of a valid highlighter as argument." |   echo >&2 "Bail out! You must provide the name of a valid highlighter as argument." | ||||||
|  |  | ||||||
|  | @ -49,12 +49,58 @@ if true; then | ||||||
|   fi |   fi | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
|  | # This function takes a single argument F and returns True iff F is an autoload stub. | ||||||
|  | _zsh_highlight__function_is_autoload_stub_p() { | ||||||
|  |   if zmodload -e zsh/parameter; then | ||||||
|  |     #(( ${+functions[$1]} )) && | ||||||
|  |     [[ "$functions[$1]" == *"builtin autoload -X"* ]] | ||||||
|  |   else | ||||||
|  |     #[[ $(type -wa -- "$1") == *'function'* ]] && | ||||||
|  |     [[ "${${(@f)"$(which -- "$1")"}[2]}" == $'\t'$histchars[3]' undefined' ]] | ||||||
|  |   fi | ||||||
|  |   # Do nothing here: return the exit code of the if. | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | # Return True iff the argument denotes a function name. | ||||||
|  | _zsh_highlight__is_function_p() { | ||||||
|  |   if zmodload -e zsh/parameter; then | ||||||
|  |     (( ${+functions[$1]} )) | ||||||
|  |   else | ||||||
|  |     [[ $(type -wa -- "$1") == *'function'* ]] | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | # This function takes a single argument F and returns True iff F denotes the | ||||||
|  | # name of a callable function.  A function is callable if it is fully defined | ||||||
|  | # or if it is marked for autoloading and autoloading it at the first call to it | ||||||
|  | # will succeed.  In particular, if F has been marked for autoloading | ||||||
|  | # but is not available in $fpath, then calling this function on F will return False. | ||||||
|  | # | ||||||
|  | # See users/21671 https://www.zsh.org/cgi-bin/mla/redirect?USERNUMBER=21671 | ||||||
|  | _zsh_highlight__function_callable_p() { | ||||||
|  |   if _zsh_highlight__is_function_p "$1" && | ||||||
|  |      ! _zsh_highlight__function_is_autoload_stub_p "$1" | ||||||
|  |   then | ||||||
|  |     # Already fully loaded. | ||||||
|  |     return 0 # true | ||||||
|  |   else | ||||||
|  |     # "$1" is either an autoload stub, or not a function at all. | ||||||
|  |     # | ||||||
|  |     # Use a subshell to avoid affecting the calling shell. | ||||||
|  |     # | ||||||
|  |     # We expect 'autoload +X' to return non-zero if it fails to fully load | ||||||
|  |     # the function. | ||||||
|  |     ( autoload -U +X -- "$1" 2>/dev/null ) | ||||||
|  |     return $? | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  | 
 | ||||||
| # ------------------------------------------------------------------------------------------------- | # ------------------------------------------------------------------------------------------------- | ||||||
| # Core highlighting update system | # Core highlighting update system | ||||||
| # ------------------------------------------------------------------------------------------------- | # ------------------------------------------------------------------------------------------------- | ||||||
| 
 | 
 | ||||||
| # Use workaround for bug in ZSH? | # Use workaround for bug in ZSH? | ||||||
| # zsh-users/zsh@48cadf4 http://www.zsh.org/mla/workers//2017/msg00034.html | # zsh-users/zsh@48cadf4 https://www.zsh.org/mla/workers/2017/msg00034.html | ||||||
| autoload -Uz is-at-least | autoload -Uz is-at-least | ||||||
| if is-at-least 5.4; then | if is-at-least 5.4; then | ||||||
|   typeset -g zsh_highlight__pat_static_bug=false |   typeset -g zsh_highlight__pat_static_bug=false | ||||||
|  | @ -77,7 +123,7 @@ _zsh_highlight() | ||||||
|   typeset -r ret |   typeset -r ret | ||||||
| 
 | 
 | ||||||
|   # $region_highlight should be predefined, either by zle or by the test suite's mock (non-special) array. |   # $region_highlight should be predefined, either by zle or by the test suite's mock (non-special) array. | ||||||
|   (( ${+region_highlight} )) || { |   (( ${+region_highlight[@]} )) || { | ||||||
|     echo >&2 'zsh-syntax-highlighting: error: $region_highlight is not defined' |     echo >&2 'zsh-syntax-highlighting: error: $region_highlight is not defined' | ||||||
|     echo >&2 'zsh-syntax-highlighting: (Check whether zsh-syntax-highlighting was installed according to the instructions.)' |     echo >&2 'zsh-syntax-highlighting: (Check whether zsh-syntax-highlighting was installed according to the instructions.)' | ||||||
|     return $ret |     return $ret | ||||||
|  | @ -109,15 +155,7 @@ _zsh_highlight() | ||||||
|         # C structs, so that none of the previous case patterns will match. |         # C structs, so that none of the previous case patterns will match. | ||||||
|         # |         # | ||||||
|         # In either case, fall back to a version check. |         # In either case, fall back to a version check. | ||||||
|         # |         if is-at-least 5.9; then | ||||||
|         # The memo= feature was added to zsh in commit zsh-5.8-172-gdd6e702ee. |  | ||||||
|         # The version number at the time was 5.8.0.2-dev (see Config/version.mk). |  | ||||||
|         # Therefore, on 5.8.0.3 and newer the memo= feature is available. |  | ||||||
|         # |  | ||||||
|         # On zsh version 5.8.0.2 between the aforementioned commit and the |  | ||||||
|         # first Config/version.mk bump after it (which, at the time of writing, |  | ||||||
|         # is yet to come), this condition will false negative. |  | ||||||
|         if is-at-least 5.8.0.3; then |  | ||||||
|           integer -gr zsh_highlight__memo_feature=1 |           integer -gr zsh_highlight__memo_feature=1 | ||||||
|         else |         else | ||||||
|           integer -gr zsh_highlight__memo_feature=0 |           integer -gr zsh_highlight__memo_feature=0 | ||||||
|  | @ -173,7 +211,8 @@ _zsh_highlight() | ||||||
|   [[ -n ${ZSH_HIGHLIGHT_MAXLENGTH:-} ]] && [[ $#BUFFER -gt $ZSH_HIGHLIGHT_MAXLENGTH ]] && return $ret |   [[ -n ${ZSH_HIGHLIGHT_MAXLENGTH:-} ]] && [[ $#BUFFER -gt $ZSH_HIGHLIGHT_MAXLENGTH ]] && return $ret | ||||||
| 
 | 
 | ||||||
|   # Do not highlight if there are pending inputs (copy/paste). |   # Do not highlight if there are pending inputs (copy/paste). | ||||||
|   [[ $PENDING -gt 0 ]] && return $ret |   (( KEYS_QUEUED_COUNT > 0 )) && return $ret | ||||||
|  |   (( PENDING > 0 )) && return $ret | ||||||
| 
 | 
 | ||||||
|   { |   { | ||||||
|     local cache_place |     local cache_place | ||||||
|  | @ -351,72 +390,113 @@ _zsh_highlight_call_widget() | ||||||
|   _zsh_highlight |   _zsh_highlight | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| # Rebind all ZLE widgets to make them invoke _zsh_highlights. | # Decide whether to use the zle-line-pre-redraw codepath (colloquially known as | ||||||
| _zsh_highlight_bind_widgets() | # "feature/redrawhook", after the topic branch's name) or the legacy "bind all | ||||||
| { | # widgets" codepath. | ||||||
|   setopt localoptions noksharrays | # | ||||||
|   typeset -F SECONDS | # We use the new codepath under two conditions: | ||||||
|   local prefix=orig-s$SECONDS-r$RANDOM # unique each time, in case we're sourced more than once | # | ||||||
| 
 | # 1. If it's available, which we check by testing for add-zle-hook-widget's availability. | ||||||
|   # Load ZSH module zsh/zleparameter, needed to override user defined widgets. | #  | ||||||
|   zmodload zsh/zleparameter 2>/dev/null || { | # 2. If zsh has the memo= feature, which is required for interoperability reasons. | ||||||
|     print -r -- >&2 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' | #    See issues #579 and #735, and the issues referenced from them. | ||||||
|     return 1 | # | ||||||
|  | #    We check this with a plain version number check, since a functional check, | ||||||
|  | #    as done by _zsh_highlight, can only be done from inside a widget | ||||||
|  | #    function — a catch-22. | ||||||
|  | if is-at-least 5.9 && _zsh_highlight__function_callable_p add-zle-hook-widget | ||||||
|  | then | ||||||
|  |   autoload -U add-zle-hook-widget | ||||||
|  |   _zsh_highlight__zle-line-finish() { | ||||||
|  |     # Reset $WIDGET since the 'main' highlighter depends on it. | ||||||
|  |     # | ||||||
|  |     # Since $WIDGET is declared by zle as read-only in this function's scope, | ||||||
|  |     # a nested function is required in order to shadow its built-in value; | ||||||
|  |     # see "User-defined widgets" in zshall. | ||||||
|  |     () { | ||||||
|  |       local -h -r WIDGET=zle-line-finish | ||||||
|  |       _zsh_highlight | ||||||
|  |     } | ||||||
|   } |   } | ||||||
|  |   _zsh_highlight__zle-line-pre-redraw() { | ||||||
|  |     # Set $? to 0 for _zsh_highlight.  Without this, subsequent | ||||||
|  |     # zle-line-pre-redraw hooks won't run, since add-zle-hook-widget happens to | ||||||
|  |     # call us with $? == 1 in the common case. | ||||||
|  |     true && _zsh_highlight "$@" | ||||||
|  |   } | ||||||
|  |   _zsh_highlight_bind_widgets(){} | ||||||
|  |   if [[ -o zle ]]; then | ||||||
|  |     add-zle-hook-widget zle-line-pre-redraw _zsh_highlight__zle-line-pre-redraw | ||||||
|  |     add-zle-hook-widget zle-line-finish _zsh_highlight__zle-line-finish | ||||||
|  |   fi | ||||||
|  | else | ||||||
|  |   # Rebind all ZLE widgets to make them invoke _zsh_highlights. | ||||||
|  |   _zsh_highlight_bind_widgets() | ||||||
|  |   { | ||||||
|  |     setopt localoptions noksharrays | ||||||
|  |     typeset -F SECONDS | ||||||
|  |     local prefix=orig-s$SECONDS-r$RANDOM # unique each time, in case we're sourced more than once | ||||||
| 
 | 
 | ||||||
|   # Override ZLE widgets to make them invoke _zsh_highlight. |     # Load ZSH module zsh/zleparameter, needed to override user defined widgets. | ||||||
|   local -U widgets_to_bind |     zmodload zsh/zleparameter 2>/dev/null || { | ||||||
|   widgets_to_bind=(${${(k)widgets}:#(.*|run-help|which-command|beep|set-local-history|yank|yank-pop)}) |       print -r -- >&2 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' | ||||||
|  |       return 1 | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|   # Always wrap special zle-line-finish widget. This is needed to decide if the |     # Override ZLE widgets to make them invoke _zsh_highlight. | ||||||
|   # current line ends and special highlighting logic needs to be applied. |     local -U widgets_to_bind | ||||||
|   # E.g. remove cursor imprint, don't highlight partial paths, ... |     widgets_to_bind=(${${(k)widgets}:#(.*|run-help|which-command|beep|set-local-history|yank|yank-pop)}) | ||||||
|   widgets_to_bind+=(zle-line-finish) |  | ||||||
| 
 | 
 | ||||||
|   # Always wrap special zle-isearch-update widget to be notified of updates in isearch. |     # Always wrap special zle-line-finish widget. This is needed to decide if the | ||||||
|   # This is needed because we need to disable highlighting in that case. |     # current line ends and special highlighting logic needs to be applied. | ||||||
|   widgets_to_bind+=(zle-isearch-update) |     # E.g. remove cursor imprint, don't highlight partial paths, ... | ||||||
|  |     widgets_to_bind+=(zle-line-finish) | ||||||
| 
 | 
 | ||||||
|   local cur_widget |     # Always wrap special zle-isearch-update widget to be notified of updates in isearch. | ||||||
|   for cur_widget in $widgets_to_bind; do |     # This is needed because we need to disable highlighting in that case. | ||||||
|     case ${widgets[$cur_widget]:-""} in |     widgets_to_bind+=(zle-isearch-update) | ||||||
| 
 | 
 | ||||||
|       # Already rebound event: do nothing. |     local cur_widget | ||||||
|       user:_zsh_highlight_widget_*);; |     for cur_widget in $widgets_to_bind; do | ||||||
|  |       case ${widgets[$cur_widget]:-""} in | ||||||
| 
 | 
 | ||||||
|       # The "eval"'s are required to make $cur_widget a closure: the value of the parameter at function |         # Already rebound event: do nothing. | ||||||
|       # definition time is used. |         user:_zsh_highlight_widget_*);; | ||||||
|       # |  | ||||||
|       # We can't use ${0/_zsh_highlight_widget_} because these widgets are always invoked with |  | ||||||
|       # NO_function_argzero, regardless of the option's setting here. |  | ||||||
| 
 | 
 | ||||||
|       # User defined widget: override and rebind old one with prefix "orig-". |         # The "eval"'s are required to make $cur_widget a closure: the value of the parameter at function | ||||||
|       user:*) zle -N $prefix-$cur_widget ${widgets[$cur_widget]#*:} |         # definition time is used. | ||||||
|               eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget ${(q)prefix}-${(q)cur_widget} -- \"\$@\" }" |         # | ||||||
|               zle -N $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;; |         # We can't use ${0/_zsh_highlight_widget_} because these widgets are always invoked with | ||||||
|  |         # NO_function_argzero, regardless of the option's setting here. | ||||||
| 
 | 
 | ||||||
|       # Completion widget: override and rebind old one with prefix "orig-". |         # User defined widget: override and rebind old one with prefix "orig-". | ||||||
|       completion:*) zle -C $prefix-$cur_widget ${${(s.:.)widgets[$cur_widget]}[2,3]}  |         user:*) zle -N $prefix-$cur_widget ${widgets[$cur_widget]#*:} | ||||||
|                     eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget ${(q)prefix}-${(q)cur_widget} -- \"\$@\" }" |                 eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget ${(q)prefix}-${(q)cur_widget} -- \"\$@\" }" | ||||||
|                     zle -N $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;; |                 zle -N $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;; | ||||||
| 
 | 
 | ||||||
|       # Builtin widget: override and make it call the builtin ".widget". |         # Completion widget: override and rebind old one with prefix "orig-". | ||||||
|       builtin) eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget .${(q)cur_widget} -- \"\$@\" }" |         completion:*) zle -C $prefix-$cur_widget ${${(s.:.)widgets[$cur_widget]}[2,3]} | ||||||
|                zle -N $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;; |                       eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget ${(q)prefix}-${(q)cur_widget} -- \"\$@\" }" | ||||||
|  |                       zle -N $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;; | ||||||
| 
 | 
 | ||||||
|       # Incomplete or nonexistent widget: Bind to z-sy-h directly. |         # Builtin widget: override and make it call the builtin ".widget". | ||||||
|       *)  |         builtin) eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget .${(q)cur_widget} -- \"\$@\" }" | ||||||
|          if [[ $cur_widget == zle-* ]] && (( ! ${+widgets[$cur_widget]} )); then |                  zle -N $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;; | ||||||
|            _zsh_highlight_widget_${cur_widget}() { :; _zsh_highlight } | 
 | ||||||
|            zle -N $cur_widget _zsh_highlight_widget_$cur_widget |         # Incomplete or nonexistent widget: Bind to z-sy-h directly. | ||||||
|          else |         *) | ||||||
|       # Default: unhandled case. |            if [[ $cur_widget == zle-* ]] && (( ! ${+widgets[$cur_widget]} )); then | ||||||
|            print -r -- >&2 "zsh-syntax-highlighting: unhandled ZLE widget ${(qq)cur_widget}" |              _zsh_highlight_widget_${cur_widget}() { :; _zsh_highlight } | ||||||
|            print -r -- >&2 "zsh-syntax-highlighting: (This is sometimes caused by doing \`bindkey <keys> ${(q-)cur_widget}\` without creating the ${(qq)cur_widget} widget with \`zle -N\` or \`zle -C\`.)" |              zle -N $cur_widget _zsh_highlight_widget_$cur_widget | ||||||
|          fi |            else | ||||||
|     esac |         # Default: unhandled case. | ||||||
|   done |              print -r -- >&2 "zsh-syntax-highlighting: unhandled ZLE widget ${(qq)cur_widget}" | ||||||
| } |              print -r -- >&2 "zsh-syntax-highlighting: (This is sometimes caused by doing \`bindkey <keys> ${(q-)cur_widget}\` without creating the ${(qq)cur_widget} widget with \`zle -N\` or \`zle -C\`.)" | ||||||
|  |            fi | ||||||
|  |       esac | ||||||
|  |     done | ||||||
|  |   } | ||||||
|  | fi | ||||||
| 
 | 
 | ||||||
| # Load highlighters from directory. | # Load highlighters from directory. | ||||||
| # | # | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue