Skip to content

Instantly share code, notes, and snippets.

@Orangenhain
Last active April 17, 2017 20:59
Show Gist options
  • Save Orangenhain/c9ac6ea47f187589813b9887c300a897 to your computer and use it in GitHub Desktop.
Save Orangenhain/c9ac6ea47f187589813b9887c300a897 to your computer and use it in GitHub Desktop.
zsh completion - partial coloring issues
# - start a clean shell with `zsh -f`
# - `source` this file
# - `a -<tab>` WILL show color
# - `a --<tab>` will NOT show color
# - `b -<tab>` will NOT show color
# - `c <tab>` will NOT show color
# if you uncomment the line after "YYY", ALL examples WILL show color
# first example shows up as expected (only option is red, rest is normal)
# but for the others, the *complete* line will be colored
# if you uncomment the line after "ZZZ", ALL examples WILL show color (complete lines, as expected)
zmodload zsh/complist
autoload -U compinit && compinit
zstyle ':completion:*' list-separator "XX"
zstyle ':completion:*:default' list-colors '=XX*=31'
# YYY
# zstyle ':completion:*:default' list-colors '=^(XX*)=31'
# ZZZ
# zstyle ':completion:*:default' list-colors '=*=31'
_a () {
_arguments \
'(--first -f)'{--first,-f}'[first should be red]' \
'--second[second should be red]'
}
compdef _a a
_b () {
_arguments \
'--second[second should be red]' \
'-t[more red arguments]'
}
compdef _b b
_c () {
local -a targets
targets=(1:"this should be red" 2:"this as well")
_describe -t targets 'stuff' targets
}
compdef _c c
@Orangenhain
Copy link
Author

Using backreferences doesn't seem to work either ... but the results seem to be the reverse of the original, case a.2 & b & c work ... but a -<tab> fails.
another_version

@Orangenhain
Copy link
Author

the plot thickens:

oh

ah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment