Syntax highlight for compleat/complgen, a unified completion generation language for multiple shells such as bash, zsh, fish and powershell.
Syntax
We prioritize syntax highlighting complgen grammars,
due to its active development and extended features over compleat.
We describe the implemented syntax rules derived from [email protected] from
README, with [CG] denoting features specific to complgen:
A usage file *.usage contains commands and definitions, separated by semicolons.
A command consists of a command name followed by a pattern. The command name can be any atom. If there is more than one command in the file, we will attempt to match each of them against the input line.
An atom consists of letters, numbers, and any of the characters _-, starting with a letter or underscore.
- Any atom matches itself:
foomatches the stringfoo. a bmatchesafollowed byb.a b | cmatches eithera borc.[a]matches zero or one occurrences ofa.a...matches one or more occurrences ofa[a]...matches zero or more occurrences ofa.- [CG]
(a | b || c)showsaandbas candidates, andconly when current input matches neitheranorb.||behaves exactly like|when matching, it differs only when offering completions.
Use parentheses to group patterns:
a (b | c)matchesafollowed by eitherborc.(a | b) ...matchesaorbfollowed by any number of additionalaorb.
Variables and Constants:
- A variable can be defined with
<FOO> = barand referenced as<FOO>. - [CG] A special variable
<_>matches any shell word. - [CG] Predefined variables (default constants, though overridable):
<PATH>and<DIRECTORY>match file and directory paths, respectively. <USER@bash>and<USER@fish>define the<USER>variable, but are shell-specific.
Attribution
Syntax based on complgen grammar by Adam Szkoda.
Icon from Keyboard-key icons created by littleicon - Flaticon.