summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Kiddle <okiddle@yahoo.co.uk>2020-07-08 17:40:42 +0200
committerOliver Kiddle <okiddle@yahoo.co.uk>2020-07-08 17:40:42 +0200
commit389c853b4acf3d5bb9f5b06aa26219ee2f5bad6c (patch)
tree41a0adfec40f4a12eb2b8a2ebad43b6e1c7bb7ae
parenta0a27473fe0e344a9deb4f042c24e31a2e22bcc5 (diff)
downloadzsh-389c853b4acf3d5bb9f5b06aa26219ee2f5bad6c.tar.gz
zsh-389c853b4acf3d5bb9f5b06aa26219ee2f5bad6c.zip
46195: use showrgb command to get colours if it is available
-rw-r--r--ChangeLog3
-rw-r--r--Completion/X/Type/_x_color13
2 files changed, 11 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 779dc67e5..6cbfe054c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2020-07-08 Oliver Kiddle <okiddle@yahoo.co.uk>
+ * 46195: Completion/X/Type/_x_color: use showrgb command to get
+ colours if it is available
+
* github #50: SATOH Fumiyasu: Completion/Unix/Type/_ssh_hosts:
Complete hosts in "Match" directive
diff --git a/Completion/X/Type/_x_color b/Completion/X/Type/_x_color
index 960eae6d3..845a35686 100644
--- a/Completion/X/Type/_x_color
+++ b/Completion/X/Type/_x_color
@@ -10,25 +10,28 @@
local expl
-if (( ! $+_color_cache )); then
+if (( ! $+_cache_x_colors )); then
+ typeset -ga _cache_x_colors
local file
# Cache of color names doesn't exist yet, create it.
zstyle -s ":completion:${curcontext}:colors" path file
if [[ -n "$file" ]]; then
- _color_cache=( "${(@)${(@f)$(< $file)}[2,-1]##* }" )
+ _cache_x_colors=( "${(@)${(@f)$(< $file)}[2,-1]##* }" )
+ elif (( $+commands[showrgb] )); then
+ _cache_x_colors=( "${(@)${(@)${(@f)$(_call_program colors showrgb)}[2,-1]##* }:#* *}" )
else
file=( /usr/{lib,{{X11R6,openwin},local{,/X11{,R6}}}/lib}/X11/rgb.txt(N) )
(( $#file )) &&
- _color_cache=( "${(@)${(@)${(@f)$(< $file[1])}[2,-1]##* }:#* *}" )
+ _cache_x_colors=( "${(@)${(@)${(@f)$(< $file[1])}[2,-1]##* }:#* *}" )
fi
# Stupid default value.
- (( $#_color_cache )) || _color_cache=(white black gray red blue green)
+ (( $#_cache_x_colors )) || _cache_x_colors=(white black gray red blue green)
fi
_wanted colors expl 'color specification' compadd "$@" -M \
- 'm:{a-z}={A-Z} m:-=\ r:[^ A-Z0-9]||[ A-Z0-9]=* r:|=*' -a - _color_cache
+ 'm:{a-z}={A-Z} m:-=\ r:[^ A-Z0-9]||[ A-Z0-9]=* r:|=*' -a - _cache_x_colors