Skip to content

[#148] command being typed as neither green nor red #244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/highlighters/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
3 changes: 3 additions & 0 deletions highlighters/main/main-highlighter.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion highlighters/main/test-data/unknown-command.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
)