Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Zsh completion #18

Closed
wants to merge 1 commit into from

2 participants

@poljar

There you go. :p

@falconindy
Owner

Pushed with some minor changes. Thanks!

@falconindy falconindy closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 9, 2011
  1. Added zsh completion

    poljar authored
This page is out of date. Refresh to see the latest.
Showing with 75 additions and 0 deletions.
  1. +75 −0 _cower
View
75 _cower
@@ -0,0 +1,75 @@
+#compdef cower
+# copy this file to /usr/share/zsh/site-functions/_cower
+typeset -A opt_args
+setopt extendedglob
+
+_cower_opts_commands=(
+ '-d[Download target(s)]'
+ '-i[Show info for target(s)]'
+ '-m[Show packages maintained by target(s)]'
+ '-s[Search for target(s)]'
+ '-u[Check for updates against AUR]'
+ '-h[Display usage]'
+)
+_cower_opts_general=(
+ '-f[Overwrite existing files when downloading]'
+ '--ignore[Ignore a package upgrade]:package:
+ _cower_completions_installed_packages'
+ '--ignorerepo[Ignore some or all binary repos]:repositories:
+ _cower_completions_repositories'
+ '--nossl[Do not use https connections]'
+ '-t[Specify an alternate download directory]:target:_files -/'
+ '--threads+[Limit number of threads created]:number of threads'
+ '--timeout+[Specify connection timeout in seconds]:timeout'
+)
+_cower_opts_output=(
+ '-c[Use colored output]'
+ '--debug[Show debug output]'
+ '--format[Print package output according to format string]'
+ '--listdelim[Change list format delimeter]'
+ '-q[Output less]'
+ '-v[Output more]'
+)
+_cower_action_none() {
+ _arguments -s : \
+ "$_cower_opts_commands[@]"
+}
+# provides completions for installed packages
+_cower_completions_installed_packages() {
+ local -a cmd packages packages_long
+ packages_long=(/var/lib/pacman/local/*(/))
+ packages=( ${${packages_long#/var/lib/pacman/local/}%-*-*} )
+ compadd "$@" -a packages
+}
+
+_cower_completions_repositories() {
+ local -a cmd repositories
+ repositories=(${(o)${${${(M)${(f)"$(</etc/pacman.conf)"}:#\[*}/\[/}/\]/}:#options})
+ # Uniq the array
+ typeset -U repositories
+ compadd "$@" -a repositories
+}
+_cower_completions_aur() {
+}
+
+_cower() {
+ case $words[2] in
+ -[ims]*) _arguments -s : \
+ "$_cower_opts_general[@]" \
+ "$_cower_opts_output[@]"
+ ;;
+ -u*) _arguments -s -w : \
+ "$_cower_opts_general[@]" \
+ "$_cower_opts_output[@]" \
+ '*-d[Download AUR dependencies]'
+ ;;
+ -d*) _arguments -s : \
+ "$_cower_opts_general[@]" \
+ "$_cower_opts_output[@]" \
+ '*-d[Download updates]' \
+ ;;
+ - ) _cower_action_none ;;
+ * ) return 1 ;;
+ esac
+}
+_cower "$@"
Something went wrong with that request. Please try again.