You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.8 KiB

пре 8 година
пре 8 година
пре 8 година
  1. zsh-syntax-highlighting / highlighters / main
  2. ---------------------------------------------
  3. This is the `main` highlighter, that highlights:
  4. * Commands
  5. * Options
  6. * Arguments
  7. * Paths
  8. * Strings
  9. This highlighter is active by default.
  10. ### How to tweak it
  11. This highlighter defines the following styles:
  12. * `unknown-token` - unknown tokens / errors
  13. * `reserved-word` - shell reserved words (`if`, `for`)
  14. * `alias` - aliases
  15. * `suffix-alias` - suffix aliases (requires zsh 5.1.1 or newer)
  16. * `builtin` - shell builtin commands (`shift`, `pwd`, `zstyle`)
  17. * `function` - function names
  18. * `command` - command names
  19. * `precommand` - precommand modifiers (e.g., `noglob`, `builtin`)
  20. * `commandseparator` - command separation tokens (`;`, `&&`)
  21. * `hashed-command` - hashed commands
  22. * `path` - existing filenames
  23. * `path_pathseparator` - path separators in filenames (`/`); if unset, `path` is used (default)
  24. * `path_prefix` - prefixes of existing filenames
  25. * `path_prefix_pathseparator` - path separators in prefixes of existing filenames (`/`); if unset, `path_prefix` is used (default)
  26. * `globbing` - globbing expressions (`*.txt`)
  27. * `history-expansion` - history expansion expressions (`!foo` and `^foo^bar`)
  28. * `single-hyphen-option` - single hyphen options (`-o`)
  29. * `double-hyphen-option` - double hyphen options (`--option`)
  30. * `back-quoted-argument` - backquoted expressions (`` `foo` ``)
  31. * `single-quoted-argument` - single quoted arguments (`` 'foo' ``)
  32. * `double-quoted-argument` - double quoted arguments (`` "foo" ``)
  33. * `dollar-quoted-argument` - dollar quoted arguments (`` $'foo' ``)
  34. * `dollar-double-quoted-argument` - parameter expansion inside double quotes (`$foo` inside `""`)
  35. * `back-double-quoted-argument` - back double quoted arguments (`\x` inside `""`)
  36. * `back-dollar-quoted-argument` - back dollar quoted arguments (`\x` inside `$''`)
  37. * `assign` - parameter assignments
  38. * `redirection` - redirection operators (`<`, `>`, etc)
  39. * `comment` - comments, when `setopt INTERACTIVE_COMMENTS` is in effect (`echo # foo`)
  40. * `default` - everything else
  41. To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
  42. for example in `~/.zshrc`:
  43. # Declare the variable
  44. typeset -A ZSH_HIGHLIGHT_STYLES
  45. # To differentiate aliases from other command types
  46. ZSH_HIGHLIGHT_STYLES[alias]='fg=magenta,bold'
  47. # To have paths colored instead of underlined
  48. ZSH_HIGHLIGHT_STYLES[path]='fg=cyan'
  49. # To disable highlighting of globbing expressions
  50. ZSH_HIGHLIGHT_STYLES[globbing]='none'
  51. The syntax for values is the same as the syntax of "types of highlighting" of
  52. the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
  53. manual page][zshzle-Character-Highlighting].
  54. [zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting