Add completion for grml-tips [Closes: issue988]
authorFrank Terbeck <ft@bewatermyfriend.org>
Wed, 11 Jan 2012 14:07:06 +0000 (15:07 +0100)
committerFrank Terbeck <ft@bewatermyfriend.org>
Wed, 11 Jan 2012 14:07:06 +0000 (15:07 +0100)
usr_share_grml/zsh/completion/grml/_grml-tips [new file with mode: 0644]

diff --git a/usr_share_grml/zsh/completion/grml/_grml-tips b/usr_share_grml/zsh/completion/grml/_grml-tips
new file mode 100644 (file)
index 0000000..27cd7db
--- /dev/null
@@ -0,0 +1,24 @@
+#compdef grml-tips
+
+local db=/usr/share/grml-tips/tags
+local -a args
+
+if [[ ! -e $db ]]; then
+    _message 'Tip database not found: `'$db\'
+    return 0
+fi
+
+__grml-tips-tags () {
+    local expl
+    local -a tags
+
+    tags=( ${(f)"$(<$db)"} )
+    _wanted tag expl 'grml-tips tag' compadd ${expl} -- ${tags}
+}
+
+args=( '--help[Display help message]'
+       '--tagsonly[Match only by tag, not by pattern]'
+       '--tipsfile[Use non-default tips-file]:_path_files'
+       '*::grml-tips tag:__grml-tips-tags' )
+
+_arguments $args