summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2014-09-17 16:59:45 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2014-10-10 16:44:40 +0200
commit504b29a475324160472fb60819d7bec6a1e45cb1 (patch)
tree0875979b84a77dc200779edcaa86867b82f34974
parent0f66088d9282543763d92209afd4d045494b8ee3 (diff)
downloadxtools-504b29a475324160472fb60819d7bec6a1e45cb1.tar.gz
xtools-504b29a475324160472fb60819d7bec6a1e45cb1.tar.xz
xtools-504b29a475324160472fb60819d7bec6a1e45cb1.zip
add zsh completion
-rw-r--r--Makefile1
-rw-r--r--_xtools74
2 files changed, 75 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 085d450..e8058b0 100644
--- a/Makefile
+++ b/Makefile
@@ -5,4 +5,5 @@ all:
 
 install:
 	for f in x*[^~]; do install -Dm0755 $$f $(DESTDIR)$(PREFIX)/bin/$$f; done
+	install -Dm644 _xtools /usr/share/zsh/site-functions/_xtools
 
diff --git a/_xtools b/_xtools
new file mode 100644
index 0000000..3389737
--- /dev/null
+++ b/_xtools
@@ -0,0 +1,74 @@
+#compdef xbulk xbump xdiff xgensum xgrep xlg xlog xls xmindep xnew xnuxnu xoptdiff xq xsrc
+
+_xbps  # force autoload
+
+_xtools_all_packages() {
+	compadd "$@" -- $(xdistdir)/srcpkgs/*(:t)
+}
+
+_xbulk() {
+	_arguments : \
+		'-n[dry-run]' \
+		'-k[keep going when a build fails]' \
+		'*:available templates:_xtools_all_packages'
+}
+
+_xtools_one_template() {
+	_arguments : \
+		':available templates:_xtools_all_packages'
+}
+
+_xdiff() {
+	_arguments : \
+		'-u[only display differences]' \
+		':directory:_files -/'
+}
+
+_xgensum() {
+	_arguments : \
+		'-i[substitute in-place]' \
+		':available templates:_xtools_all_packages'
+}
+
+_xgrep() {
+	_arguments : \
+		'1:pattern: ' \
+		'*:package:_xbps_installed_packages'
+}
+
+_xtools_just_packages() {
+	_arguments : \
+		'*:package:_xbps_all_packages'
+}
+
+_xoptdiff() {
+	_arguments : \
+		'-q[only list differing packages]' \
+		'*:package:_xbps_installed_packages'
+}
+
+_xq() {
+	_arguments : \
+		'-R[include remote information too]' \
+		'*:package:_xbps_all_packages'
+}
+
+_xtools() {
+        case "$service" in
+		xbulk) _xbulk "$@";;
+		xbump) _xtools_one_template "$@";;
+		xdiff) _xdiff "$@";;
+		xgensum) _xgensum "$@";;
+		xgrep) _xgrep "$@";;
+		xlg) _xtools_one_template "$@";;
+		xlog) _xtools_one_template "$@";;
+		xls) _xtools_just_packages "$@";;
+		xmindep) _xtools_just_packages "$@";;
+		xnuxnu) _xtools_one_template "$@";;
+		xoptdiff) _xoptdiff "$@";;
+		xq) _xq "$@";;
+		xsrc) _xtool_one_template "$@";;
+        esac
+}
+
+_xtools "$@"