summaryrefslogtreecommitdiff
path: root/Completion/X/Command
diff options
context:
space:
mode:
authorOliver Kiddle <okiddle@yahoo.co.uk>2018-08-24 07:49:02 +0200
committerOliver Kiddle <okiddle@yahoo.co.uk>2018-08-24 08:04:12 +0200
commitf4a1c3c4a34f9a7d2572be5a8811576566fc3ebf (patch)
tree9dcf2a13438f9fc97f52597303e4bdb11d620e14 /Completion/X/Command
parent7bf4f03eb3bef10d324c14c417f8f3b356cd3a42 (diff)
downloadzsh-f4a1c3c4a34f9a7d2572be5a8811576566fc3ebf.tar.gz
zsh-f4a1c3c4a34f9a7d2572be5a8811576566fc3ebf.zip
43328: new zeal completion
Diffstat (limited to 'Completion/X/Command')
-rw-r--r--Completion/X/Command/_zeal43
1 files changed, 43 insertions, 0 deletions
diff --git a/Completion/X/Command/_zeal b/Completion/X/Command/_zeal
new file mode 100644
index 000000000..334331d40
--- /dev/null
+++ b/Completion/X/Command/_zeal
@@ -0,0 +1,43 @@
+#compdef zeal
+
+local curcontext="$curcontext" cfg docset setdir mbegin mend ret=1
+local -a state line expl suf docsets globbed match
+local -A opt_args dsets
+
+_arguments -S \
+ ':query:->queries' \
+ + '(opt)' \
+ {-h,--help}'[display help information]' \
+ {-v,--version}'[display version information]' \
+ {-f,--force}'[force the application to run]' && ret=0
+
+if [[ -n $state ]]; then
+ cfg=${XDG_CONFIG_HOME:-~/.config}/Zeal/Zeal.conf
+ if [[ -r $cfg ]]; then
+ docsets=${${(M)${(f)"$(<$cfg)"}:#path=*}#path=}
+ else
+ docsets=${XDG_DATA_HOME:-~/.local/share}/Zeal/Zeal/docsets
+ fi
+ for docset in $docsets/*.docset/Contents/Info.plist(N); do
+ setdir=${docset:h:h:r:t:l:gs/+/p}
+ [[ $(<$docset) = *DocSetPlatformFamily\<[^\<]#\<string\>(#b)([^\<]#)* ]] ||
+ match=( ${docset:h:h:r:t:l:gs/+/p} )
+ dsets+=( $match[1] ${docset:h} )
+ done
+ if compset -P 1 '*:'; then
+ globbed=( ${dsets[${IPREFIX%:}]}/Resources/docSet.dsidx(N[1]) )
+ if (( $+commands[sqlite3] )) && [[ -e $globbed ]]; then
+ _description queries expl 'query'
+ compadd "$expl[@]" - ${(f)"$(_call_program queries
+ sqlite3 $globbed 'select name from searchIndex')"} && ret=0
+ else
+ _message -e queries 'query'
+ fi
+ else
+ compset -S ':*' || suf=( -qS : )
+ _description docsets expl 'docset'
+ compadd "$expl[@]" $suf -k dsets && ret=0
+ fi
+fi
+
+return ret