1zsh-syntax-highlighting / highlighters / main 2--------------------------------------------- 3 4This is the `main` highlighter, that highlights: 5 6* Commands 7* Options 8* Arguments 9* Paths 10* Strings 11 12This highlighter is active by default. 13 14 15### How to tweak it 16 17This highlighter defines the following styles: 18 19* `unknown-token` - unknown tokens / errors 20* `reserved-word` - shell reserved words (`if`, `for`) 21* `alias` - aliases 22* `suffix-alias` - suffix aliases (requires zsh 5.1.1 or newer) 23* `builtin` - shell builtin commands (`shift`, `pwd`, `zstyle`) 24* `function` - function names 25* `command` - command names 26* `precommand` - precommand modifiers (e.g., `noglob`, `builtin`) 27* `commandseparator` - command separation tokens (`;`, `&&`) 28* `hashed-command` - hashed commands 29* `path` - existing filenames 30* `path_pathseparator` - path separators in filenames (`/`); if unset, `path` is used (default) 31* `path_prefix` - prefixes of existing filenames 32* `path_prefix_pathseparator` - path separators in prefixes of existing filenames (`/`); if unset, `path_prefix` is used (default) 33* `globbing` - globbing expressions (`*.txt`) 34* `history-expansion` - history expansion expressions (`!foo` and `^foo^bar`) 35* `command-substitution` - command substitutions (`$(echo foo)`) 36* `command-substitution-unquoted` - an unquoted command substitution (`$(echo foo)`) 37* `command-substitution-quoted` - a quoted command substitution (`"$(echo foo)"`) 38* `command-substitution-delimiter` - command substitution delimiters (`$(` and `)`) 39* `command-substitution-delimiter-unquoted` - an unquoted command substitution delimiters (`$(` and `)`) 40* `command-substitution-delimiter-quoted` - a quoted command substitution delimiters (`"$(` and `)"`) 41* `process-substitution` - process substitutions (`<(echo foo)`) 42* `process-substitution-delimiter` - process substitution delimiters (`<(` and `)`) 43* `single-hyphen-option` - single-hyphen options (`-o`) 44* `double-hyphen-option` - double-hyphen options (`--option`) 45* `back-quoted-argument` - backtick command substitution (`` `foo` ``) 46* `back-quoted-argument-unclosed` - unclosed backtick command substitution (`` `foo ``) 47* `back-quoted-argument-delimiter` - backtick command substitution delimiters (`` ` ``) 48* `single-quoted-argument` - single-quoted arguments (`` 'foo' ``) 49* `single-quoted-argument-unclosed` - unclosed single-quoted arguments (`` 'foo ``) 50* `double-quoted-argument` - double-quoted arguments (`` "foo" ``) 51* `double-quoted-argument-unclosed` - unclosed double-quoted arguments (`` "foo ``) 52* `dollar-quoted-argument` - dollar-quoted arguments (`` $'foo' ``) 53* `dollar-quoted-argument-unclosed` - unclosed dollar-quoted arguments (`` $'foo ``) 54* `rc-quote` - two single quotes inside single quotes when the `RC_QUOTES` option is set (`` 'foo''bar' ``) 55* `dollar-double-quoted-argument` - parameter expansion inside double quotes (`$foo` inside `""`) 56* `back-double-quoted-argument` - backslash escape sequences inside double-quoted arguments (`\"` in `"foo\"bar"`) 57* `back-dollar-quoted-argument` - backslash escape sequences inside dollar-quoted arguments (`\x` in `$'\x48'`) 58* `assign` - parameter assignments (`x=foo` and `x=( )`) 59* `redirection` - redirection operators (`<`, `>`, etc) 60* `comment` - comments, when `setopt INTERACTIVE_COMMENTS` is in effect (`echo # foo`) 61* `named-fd` - named file descriptor (`echo foo {fd}>&2`) 62* `arg0` - a command word other than one of those enumerated above (other than a command, precommand, alias, function, or shell builtin command). 63* `default` - everything else 64 65To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, 66for example in `~/.zshrc`: 67 68```zsh 69# Declare the variable 70typeset -A ZSH_HIGHLIGHT_STYLES 71 72# To differentiate aliases from other command types 73ZSH_HIGHLIGHT_STYLES[alias]='fg=magenta,bold' 74 75# To have paths colored instead of underlined 76ZSH_HIGHLIGHT_STYLES[path]='fg=cyan' 77 78# To disable highlighting of globbing expressions 79ZSH_HIGHLIGHT_STYLES[globbing]='none' 80``` 81 82The syntax for values is the same as the syntax of "types of highlighting" of 83the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` 84manual page][zshzle-Character-Highlighting]. 85 86#### Parameters 87 88To avoid partial path lookups on a path, add the path to the `ZSH_HIGHLIGHT_DIRS_BLACKLIST` array. 89 90```zsh 91ZSH_HIGHLIGHT_DIRS_BLACKLIST+=(/mnt/slow_share) 92``` 93 94### Useless trivia 95 96#### Forward compatibility. 97 98zsh-syntax-highlighting attempts to be forward-compatible with zsh. 99Specifically, we attempt to facilitate highlighting _command word_ types that 100had not yet been invented when this version of zsh-syntax-highlighting was 101released. 102 103A _command word_ is something like a function name, external command name, et 104cetera. (See 105[Simple Commands & Pipelines in `zshmisc(1)`][zshmisc-Simple-Commands-And-Pipelines] 106for a formal definition.) 107 108If a new _kind_ of command word is ever added to zsh — something conceptually 109different than "function" and "alias" and "external command" — then command words 110of that (new) kind will be highlighted by the style `arg0_$kind`, 111where `$kind` is the output of `type -w` on the new kind of command word. If that 112style is not defined, then the style `arg0` will be used instead. 113 114[zshmisc-Simple-Commands-And-Pipelines]: http://zsh.sourceforge.net/Doc/Release/Shell-Grammar.html#Simple-Commands-_0026-Pipelines 115 116[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting 117