Skip to content
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

Add common substring highlight customization #727

Open
wants to merge 2 commits into
base: main
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
5 changes: 4 additions & 1 deletion Completions/_autocomplete__unambiguous
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ _requested $tag ||

typeset -g _autocomplete__unambiguous="$compstate[unambiguous]"

builtin compadd -J "$tag" -x $'%{\e[0;2m%}%Bcommon substring:%b %F{0}%K{11}'"$compstate[unambiguous]%f%k"
# Retrieve highlight value
builtin zstyle -s ":autocomplete:$curcontext" common-substring-highlight highlight

builtin compadd -J "$tag" -x $'%{\e[0;2m%}%Bcommon substring:%b '"$highlight""$compstate[unambiguous]%f%k"

false
3 changes: 3 additions & 0 deletions Functions/Init/.autocomplete__config
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ builtin zstyle ':completion:*:default' select-prompt '%F{black}%K{12}line %l %p%
builtin zstyle ':completion:*' insert-sections yes
builtin zstyle ':completion:*' separate-sections yes

builtin zstyle ':autocomplete:*' common-substring-highlight '%F{0}%K{11}'


# Needed for _gnu_generic to prevent descriptions from getting cropped.
is-at-least 5.9 ||
builtin zstyle ':completion:*' command '- COLUMNS=999'
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ zstyle ':completion:*:*' matcher-list 'm:{[:lower:]-}={[:upper:]_}' '+r:|[.]=**'
Note, though, that this will also slightly change what completions are listed initially. This is a
limitation of the underlying implementation in Zsh.

### Customizing Colors for common-substring-highlight
You can customize the colors used for highlighting the common substring by changing the last string in the following zstyle:
```zsh
builtin zstyle ':autocomplete:*' common-substring-highlight '%F{0}%K{11}'
```
You can control the foreground and background colors:
- Foreground Color (%F{X}): The value inside the curly braces (X) corresponds to the text color.
- Background Color (%K{Y}): The value inside the curly braces (Y) corresponds to the background color.

### Make <kbd>Enter</kbd> submit the command line straight from the menu
By default, pressing <kbd>Enter</kbd> in the menu search exits the search and
pressing it otherwise in the menu exits the menu. If you instead want to make
Expand Down
Loading