From 7f6ce5326c8d09230ef819f5aaa1a0d321919f80 Mon Sep 17 00:00:00 2001 From: Jason Ryan Date: Thu, 21 Aug 2014 06:26:31 +1200 Subject: Initial commit of zsh completion --- Makefile | 4 ++++ shell/zsh-completion | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 shell/zsh-completion diff --git a/Makefile b/Makefile index ea1c171..e01c275 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,9 @@ MANPAGES = \ BASH_COMPLETION = \ shell/bash-completion +ZSH_COMPLETION = \ + shell/zsh-completion + INCLUDES = \ package.inc.sh \ remote.inc.sh \ @@ -43,6 +46,7 @@ install: all install -m755 $(BINPROGS) $(DESTDIR)$(PREFIX)/bin install -m644 $(MANPAGES) $(DESTDIR)$(PREFIX)/share/man/man1 install -Dm644 $(BASH_COMPLETION) $(DESTDIR)$(PREFIX)/share/bash-completion/completions/asp + install -Dm644 $(ZSH_COMPLETION) $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_asp dist: git archive --format=tar --prefix=$(PACKAGE_NAME)-$(VER)/ $(VER) | gzip -9 > $(PACKAGE_NAME)-$(VER).tar.gz diff --git a/shell/zsh-completion b/shell/zsh-completion new file mode 100644 index 0000000..e26718b --- /dev/null +++ b/shell/zsh-completion @@ -0,0 +1,46 @@ +#compdef asp + +_asp_command() { + local -a _asp_cmds + _asp_cmds=( + 'checkout' + 'difflog' + 'export' + 'gc' + 'disk-usage' + 'help' + 'list-all' + 'list-arches' + 'list-local' + 'list-repos' + 'log' + 'shortlog' + 'update' + 'untrack' + ) + +if (( CURRENT == 1 )); then + _describe -t commands 'asp command' _asp_cmds || compadd "$@" +else + local curcontext="$curcontext" + cmd="${${_asp_cmds[(r)$words[1]:*]%%:*}}" + if (( $#cmd )); then + if (( $+functions[_asp_$cmd] )); then + _asp_$cmd + else + _message "no more options" + fi + else + _message "unknown asp command: $words[1]" + fi +fi +} + +_arguments \ + '-a[architecture]' \ + '-f[overwrite files]' \ + '-h[print help and exit]' \ + '-V[print version and exit]' \ + '*::asp command:_asp_command' + +# vim: set et sw=2 ts=2 ft=zsh : -- cgit v1.2.3-54-g00ecf