mirror of
https://github.com/zsh-users/zsh-syntax-highlighting.git
synced 2025-02-13 10:05:31 +08:00
command word: Avoid unknown-token highlighting whilst inputting the command word.
Adds the 'command-being-input' highlight. Builds on top of the 'command-word-separator-v1' branch from PR #243.
This commit is contained in:
parent
09c4114eb9
commit
e13c86dfc2
@ -26,6 +26,7 @@ This highlighter defines the following styles:
|
||||
* `precommand` - precommand modifiers (e.g., `noglob`, `builtin`)
|
||||
* `commandseparator` - command separation tokens (`;`, `&&`)
|
||||
* `hashed-command` - hashed commands
|
||||
* `command-being-typed` - prefix of a command/function/alias that isn't one itself (e.g., `sourc`, `ifconfi`)
|
||||
* `path` - existing filenames
|
||||
* `path_prefix` - prefixes of existing filenames
|
||||
* `globbing` - globbing expressions (`*.txt`)
|
||||
|
@ -40,6 +40,7 @@
|
||||
: ${ZSH_HIGHLIGHT_STYLES[precommand]:=fg=green,underline}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[commandseparator]:=none}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[hashed-command]:=fg=green}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[command-being-typed]:=fg=yellow,underline}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[path]:=underline}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[path_prefix]:=underline}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[globbing]:=fg=blue}
|
||||
@ -347,6 +348,8 @@ _zsh_highlight_main_highlighter()
|
||||
else
|
||||
if _zsh_highlight_main_highlighter_check_path; then
|
||||
style=$ZSH_HIGHLIGHT_STYLES[path]
|
||||
elif (( ${#BUFFER} == $end_pos )); then
|
||||
style=$ZSH_HIGHLIGHT_STYLES[command-being-typed]
|
||||
else
|
||||
style=$ZSH_HIGHLIGHT_STYLES[unknown-token]
|
||||
fi
|
||||
|
@ -27,8 +27,10 @@
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
BUFFER='azertyuiop'
|
||||
# Do not append to the BUFFER; the second instance tests an "at end of BUFFER" feature.
|
||||
BUFFER='azertyuiop; azertyuiop'
|
||||
|
||||
expected_region_highlight=(
|
||||
"1 10 $ZSH_HIGHLIGHT_STYLES[unknown-token]" # azertyuiop
|
||||
"13 22 $ZSH_HIGHLIGHT_STYLES[command-being-typed]" # azertyuiop, at end of buffer
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user