summaryrefslogtreecommitdiff
path: root/completion/_flatpak
diff options
context:
space:
mode:
authorThayne McCombs <astrothayne@gmail.com>2018-05-28 22:56:50 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2018-05-29 08:17:26 +0000
commit95ca8a8232bf6d885fe5edf4e51c945e111cae91 (patch)
tree55d53047a0ab0201bb3afd391847c07f0c479e7c /completion/_flatpak
parent622f2590a64f71ad632ef98120f1ff9efd8d5c3e (diff)
downloadflatpak-95ca8a8232bf6d885fe5edf4e51c945e111cae91.tar.gz
Add zsh completion script
Fixes #103 Closes: #1727 Approved by: alexlarsson
Diffstat (limited to 'completion/_flatpak')
-rw-r--r--completion/_flatpak27
1 files changed, 27 insertions, 0 deletions
diff --git a/completion/_flatpak b/completion/_flatpak
new file mode 100644
index 00000000..e2995a2c
--- /dev/null
+++ b/completion/_flatpak
@@ -0,0 +1,27 @@
+#compdef flatpak
+
+emulate -L zsh
+
+local index
+(( index = ${(c)#words[0,CURRENT]} + $#PREFIX + 1 ))
+
+
+local resp=($(flatpak complete "$words" $index "$words[CURRENT]"))
+
+_description options opt_expl option
+_description arguments arg_expl argument
+
+local match
+for match in $resp; do
+ case $match in
+ __FLATPAK_FILE) _files;;
+ __FLATPAK_BUNDLE_FILE) _path_files -g '*.flatpak';;
+ __FLATPAK_BUNDLE_OR_REF_FILE) _path_files -g '*.flatpak(|ref)';;
+ __FLATPAK_DIR) _path_files -/;;
+ -*=) compadd $opt_expl[@] -S "" -- $match;;
+ -*) compadd $opt_expl[@] -- $match;;
+ *) compadd $arg_expl[@] $match;;
+ esac
+done
+
+# vim: ft=zsh