[pacman-dev] [PATCH 1/4] zsh completion: add deptest and database
Signed-off-by: Daniel Wallace <danielwallace@gtmanfred.com> --- contrib/zsh_completion.in | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/contrib/zsh_completion.in b/contrib/zsh_completion.in index 84ee93c..a40192c 100644 --- a/contrib/zsh_completion.in +++ b/contrib/zsh_completion.in @@ -6,9 +6,11 @@ typeset -A opt_args # options for passing to _arguments: main pacman commands _pacman_opts_commands=( + '-D[Modify database]' '-Q[Query the package database]' '-R[Remove a package from the system]' '-S[Synchronize packages]' + '-T[Check if dependencies are installed]' '-U[Upgrade a package]' '-V[Display version and exit]' '-h[Display usage]' @@ -71,6 +73,11 @@ _pacman_opts_remove=( '*:installed package:_pacman_completions_installed_packages' ) +_pacman_opts_database=( + '--asdeps[mark packages as non-explicitly installed]' + '--asexplicit[mark packages as explicitly installed]' +) + # options for passing to _arguments: options for --sync command _pacman_opts_sync_actions=( '*-c[Remove old packages from cache]:*:clean:->sync_clean' @@ -164,6 +171,16 @@ _pacman_action_remove() { "$_pacman_opts_remove[@]" } +# handles --database subcommand +_pacman_action_database() { + _arguments -s : \ + '-D' \ + "$_pacman_opts_common[@]" \ + "$_pacman_opts_database[@]" +} + + + # handles --sync subcommand _pacman_action_sync() { local context state line @@ -309,6 +326,13 @@ _pacman_zsh_comp() { -Q*) _pacman_action_query ;; -R*) _pacman_action_remove ;; -S*c*) # no completion + -T*) + _arguments -s : \ + '-T' \ + "$_pacman_opts_common[@]" \ + ":packages:_pacman_all_packages" + ;; + -D*) _pacman_action_database ;; return 0 ;; -S*l*) # repos -- 1.8.1.5
Before this, if you do pacman -Sy<tab> it completes to -y. Now, with -S and the other operations in the actual option _arguments, it won't remove the operations. Signed-off-by: Daniel Wallace <danielwallace@gtmanfred.com> --- contrib/zsh_completion.in | 66 ++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/contrib/zsh_completion.in b/contrib/zsh_completion.in index a40192c..a92b96a 100644 --- a/contrib/zsh_completion.in +++ b/contrib/zsh_completion.in @@ -43,6 +43,7 @@ _pacman_opts_pkgfile=( # options for passing to _arguments: subactions for --query command _pacman_opts_query_actions=( + '-Q' '-g[View all members of a package group]:*:package groups:->query_group' '-o[Query the package that owns a file]:file:_files' '-p[Package file to query]:*:package file:->query_file' @@ -59,6 +60,7 @@ _pacman_opts_query_modifiers=( '-k[Check package files]' '-l[List package contents]' '-m[List installed packages not found in sync db(s)]' + '-n[List installed packages found in sync db(s)]' '-t[List packages not required by any package]' '-u[List packages that can be upgraded]' ) @@ -80,6 +82,7 @@ _pacman_opts_database=( # options for passing to _arguments: options for --sync command _pacman_opts_sync_actions=( + '-S' '*-c[Remove old packages from cache]:*:clean:->sync_clean' '*-cc[Remove all packages from cache]:*:clean:->sync_clean' '-g[View all members of a package group]:*:package groups:->sync_group' @@ -124,11 +127,6 @@ _pacman_action_query() { local context state line typeset -A opt_args -# _arguments -s : \ -# "$_pacman_opts_common[@]" \ -# "$_pacman_opts_query_actions[@]" \ -# "$_pacman_opts_query_modifiers[@]" - case $state in query_file) _arguments -s : \ @@ -167,6 +165,7 @@ _pacman_action_query() { # handles --remove subcommand _pacman_action_remove() { _arguments -s : \ + '-R' \ "$_pacman_opts_common[@]" \ "$_pacman_opts_remove[@]" } @@ -186,11 +185,6 @@ _pacman_action_sync() { local context state line typeset -A opt_args -# _arguments -s : \ -# "$_pacman_opts_common[@]" \ -# "$_pacman_opts_sync_actions[@]" #\ -# #"$_pacman_opts_sync_modifiers[@]" - case $state in sync_clean) _arguments -s : \ @@ -213,6 +207,7 @@ _pacman_action_sync() { *) _arguments -s : \ "$_pacman_opts_common[@]" \ + "$_pacman_opts_sync_actions[@]" \ "$_pacman_opts_sync_modifiers[@]" \ '*:package:_pacman_completions_all_packages' ;; @@ -222,6 +217,7 @@ _pacman_action_sync() { # handles --upgrade subcommand _pacman_action_upgrade() { _arguments -s : \ + '-U' \ "$_pacman_opts_common[@]" \ "$_pacman_opts_pkgfile[@]" } @@ -279,6 +275,12 @@ _pacman_completions_installed_packages() { compadd "$@" -a packages } +_pacman_all_packages() { + _alternative : \ + 'localpkgs:local packages:_pacman_completions_installed_packages' \ + 'repopkgs:repository packages:_pacman_completions_all_packages' +} + # provides completions for repository names _pacman_completions_repositories() { local -a cmd repositories @@ -304,55 +306,65 @@ _pacman_get_command() { # main dispatcher _pacman_zsh_comp() { - case $words[2] in - -Q*g*) # ipkg groups + local -a args; + args=( ${${${(M)words:#-*}#-}:#-*} ) + case $args in #$words[2] in + h*) + if (( ${(c)#args} <= 1 )); then + _pacman_action_help + else + _message "no more arguments" + fi + ;; + *h*) + _message "no more arguments" + ;; + Q*g*) # ipkg groups _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_query_modifiers[@]" \ '*:groups:_pacman_completions_installed_groups' ;; - -Q*o*) # file + Q*o*) # file _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_query_modifiers[@]" \ '*:package file:_files' ;; - -Q*p*) # file *.pkg.tar* + Q*p*) # file *.pkg.tar* _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_query_modifiers[@]" \ '*:package file:_files -g "*.pkg.tar*"' ;; - -Q*) _pacman_action_query ;; - -R*) _pacman_action_remove ;; - -S*c*) # no completion - -T*) + T*) _arguments -s : \ '-T' \ "$_pacman_opts_common[@]" \ ":packages:_pacman_all_packages" ;; - -D*) _pacman_action_database ;; + Q*) _pacman_action_query ;; + R*) _pacman_action_remove ;; + D*) _pacman_action_database ;; + S*c*) # no completion return 0 ;; - -S*l*) # repos + S*l*) # repos _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_sync_modifiers[@]" \ '*:package repo:_pacman_completions_repositories' \ ;; - -S*g*) # pkg groups + S*g*) # pkg groups _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_sync_modifiers[@]" \ '*:package group:_pacman_completions_all_groups' ;; - -S*) _pacman_action_sync ;; - -U*) _pacman_action_upgrade ;; - -V*) _pacman_action_version ;; - -h*) _pacman_action_help ;; - - ) _pacman_action_none ;; - * ) return 1 ;; + S*) _pacman_action_sync ;; + U*) _pacman_action_upgrade ;; + V*) _pacman_action_version ;; + * ) _pacman_action_none ;; esac } -- 1.8.1.5
On 07/03/13 07:13, Daniel Wallace wrote:
Before this, if you do pacman -Sy<tab> it completes to -y. Now, with -S and the other operations in the actual option _arguments, it won't remove the operations.
Signed-off-by: Daniel Wallace <danielwallace@gtmanfred.com> --- contrib/zsh_completion.in | 66 ++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 27 deletions(-)
diff --git a/contrib/zsh_completion.in b/contrib/zsh_completion.in index a40192c..a92b96a 100644 --- a/contrib/zsh_completion.in +++ b/contrib/zsh_completion.in @@ -43,6 +43,7 @@ _pacman_opts_pkgfile=(
# options for passing to _arguments: subactions for --query command _pacman_opts_query_actions=( + '-Q' '-g[View all members of a package group]:*:package groups:->query_group' '-o[Query the package that owns a file]:file:_files' '-p[Package file to query]:*:package file:->query_file' @@ -59,6 +60,7 @@ _pacman_opts_query_modifiers=( '-k[Check package files]' '-l[List package contents]' '-m[List installed packages not found in sync db(s)]' + '-n[List installed packages found in sync db(s)]'
Indenting...
'-t[List packages not required by any package]' '-u[List packages that can be upgraded]' ) @@ -80,6 +82,7 @@ _pacman_opts_database=(
# options for passing to _arguments: options for --sync command _pacman_opts_sync_actions=( + '-S' '*-c[Remove old packages from cache]:*:clean:->sync_clean' '*-cc[Remove all packages from cache]:*:clean:->sync_clean' '-g[View all members of a package group]:*:package groups:->sync_group' @@ -124,11 +127,6 @@ _pacman_action_query() { local context state line typeset -A opt_args
-# _arguments -s : \ -# "$_pacman_opts_common[@]" \ -# "$_pacman_opts_query_actions[@]" \ -# "$_pacman_opts_query_modifiers[@]" - case $state in query_file) _arguments -s : \ @@ -167,6 +165,7 @@ _pacman_action_query() { # handles --remove subcommand _pacman_action_remove() { _arguments -s : \ + '-R' \ "$_pacman_opts_common[@]" \ "$_pacman_opts_remove[@]" } @@ -186,11 +185,6 @@ _pacman_action_sync() { local context state line typeset -A opt_args
-# _arguments -s : \ -# "$_pacman_opts_common[@]" \ -# "$_pacman_opts_sync_actions[@]" #\ -# #"$_pacman_opts_sync_modifiers[@]" - case $state in sync_clean) _arguments -s : \ @@ -213,6 +207,7 @@ _pacman_action_sync() { *) _arguments -s : \ "$_pacman_opts_common[@]" \ + "$_pacman_opts_sync_actions[@]" \ "$_pacman_opts_sync_modifiers[@]" \ '*:package:_pacman_completions_all_packages' ;; @@ -222,6 +217,7 @@ _pacman_action_sync() { # handles --upgrade subcommand _pacman_action_upgrade() { _arguments -s : \ + '-U' \ "$_pacman_opts_common[@]" \ "$_pacman_opts_pkgfile[@]" } @@ -279,6 +275,12 @@ _pacman_completions_installed_packages() { compadd "$@" -a packages }
+_pacman_all_packages() { + _alternative : \ + 'localpkgs:local packages:_pacman_completions_installed_packages' \ + 'repopkgs:repository packages:_pacman_completions_all_packages' +} + # provides completions for repository names _pacman_completions_repositories() { local -a cmd repositories @@ -304,55 +306,65 @@ _pacman_get_command() {
# main dispatcher _pacman_zsh_comp() { - case $words[2] in - -Q*g*) # ipkg groups + local -a args; + args=( ${${${(M)words:#-*}#-}:#-*} ) + case $args in #$words[2] in + h*) + if (( ${(c)#args} <= 1 )); then + _pacman_action_help + else + _message "no more arguments" + fi + ;; + *h*) + _message "no more arguments" + ;; + Q*g*) # ipkg groups _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_query_modifiers[@]" \ '*:groups:_pacman_completions_installed_groups' ;; - -Q*o*) # file + Q*o*) # file _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_query_modifiers[@]" \ '*:package file:_files' ;; - -Q*p*) # file *.pkg.tar* + Q*p*) # file *.pkg.tar* _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_query_modifiers[@]" \ '*:package file:_files -g "*.pkg.tar*"' ;; - -Q*) _pacman_action_query ;; - -R*) _pacman_action_remove ;; - -S*c*) # no completion - -T*) + T*) _arguments -s : \ '-T' \ "$_pacman_opts_common[@]" \ ":packages:_pacman_all_packages" ;; - -D*) _pacman_action_database ;; + Q*) _pacman_action_query ;; + R*) _pacman_action_remove ;; + D*) _pacman_action_database ;; + S*c*) # no completion return 0 ;;
And it seems you recovered from the error in the last patch... Fix it in first patch to reduce churn.
- -S*l*) # repos + S*l*) # repos _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_sync_modifiers[@]" \ '*:package repo:_pacman_completions_repositories' \ ;; - -S*g*) # pkg groups + S*g*) # pkg groups _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_sync_modifiers[@]" \ '*:package group:_pacman_completions_all_groups' ;; - -S*) _pacman_action_sync ;; - -U*) _pacman_action_upgrade ;; - -V*) _pacman_action_version ;; - -h*) _pacman_action_help ;; - - ) _pacman_action_none ;; - * ) return 1 ;; + S*) _pacman_action_sync ;; + U*) _pacman_action_upgrade ;; + V*) _pacman_action_version ;; + * ) _pacman_action_none ;; esac }
--- contrib/zsh_completion.in | 230 ++++++++++++++++++++++++++-------------------- 1 file changed, 128 insertions(+), 102 deletions(-) diff --git a/contrib/zsh_completion.in b/contrib/zsh_completion.in index a92b96a..515320c 100644 --- a/contrib/zsh_completion.in +++ b/contrib/zsh_completion.in @@ -133,32 +133,32 @@ _pacman_action_query() { "$_pacman_opts_common[@]" \ "$_pacman_opts_query_modifiers[@]" \ '*:package file:_files -g "*.pkg.tar*"' - ;; + ;; query_group) _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_query_modifiers[@]" \ '*:groups:_pacman_completions_installed_groups' - ;; + ;; query_owner) _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_query_modifiers[@]" \ '*:file:_files' - ;; + ;; query_search) _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_query_modifiers[@]" \ '*:search text: ' - ;; + ;; *) _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_query_actions[@]" \ "$_pacman_opts_query_modifiers[@]" \ '*:package:_pacman_completions_installed_packages' - ;; + ;; esac } @@ -191,27 +191,27 @@ _pacman_action_sync() { "$_pacman_opts_common[@]" \ "$_pacman_opts_sync_modifiers[@]" \ '*-c[Remove old packages from cache]' \ - ;; + ;; sync_group) _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_sync_modifiers[@]" \ '*:package group:_pacman_completions_all_groups' - ;; + ;; sync_search) _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_sync_modifiers[@]" \ '*:search text: ' - ;; + ;; *) _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_sync_actions[@]" \ "$_pacman_opts_sync_modifiers[@]" \ '*:package:_pacman_completions_all_packages' - ;; - esac + ;; + esac } # handles --upgrade subcommand @@ -324,28 +324,34 @@ _pacman_zsh_comp() { "$_pacman_opts_common[@]" \ "$_pacman_opts_query_modifiers[@]" \ '*:groups:_pacman_completions_installed_groups' - ;; + ;; Q*o*) # file _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_query_modifiers[@]" \ '*:package file:_files' - ;; + ;; Q*p*) # file *.pkg.tar* _arguments -s : \ "$_pacman_opts_common[@]" \ "$_pacman_opts_query_modifiers[@]" \ '*:package file:_files -g "*.pkg.tar*"' - ;; + ;; T*) - _arguments -s : \ + _arguments -s : \ '-T' \ "$_pacman_opts_common[@]" \ ":packages:_pacman_all_packages" - ;; - Q*) _pacman_action_query ;; - R*) _pacman_action_remove ;; - D*) _pacman_action_database ;; + ;; + Q*) + _pacman_action_query + ;; + R*) + _pacman_action_remove + ;; + D*) + _pacman_action_database + ;; S*c*) # no completion return 0 ;; @@ -360,11 +366,19 @@ _pacman_zsh_comp() { "$_pacman_opts_common[@]" \ "$_pacman_opts_sync_modifiers[@]" \ '*:package group:_pacman_completions_all_groups' - ;; - S*) _pacman_action_sync ;; - U*) _pacman_action_upgrade ;; - V*) _pacman_action_version ;; - * ) _pacman_action_none ;; + ;; + S*) + _pacman_action_sync + ;; + U*) + _pacman_action_upgrade + ;; + V*) + _pacman_action_version + ;; + *) + _pacman_action_none + ;; esac } @@ -379,7 +393,7 @@ _key_shortopts=( '-u[Update the trustdb of pacman]' '-v[Verify the file specified by the signature]: :_files -g "*.sig"' '-V[Show program version]' - ) +) _key_longopts=( '--help[show help]' @@ -400,48 +414,50 @@ _key_longopts=( '--lsign-key[Locally sign the specified keyid]:*: :_keys' '--populate[Reload the default keys from the (given) keyrings in '/usr/share/pacman/keyrings']: :_path_files -W /usr/share/pacman/keyrings' '--refresh-keys[Update specified or all keys from a keyserver]:*: :_keys' - ) +) _pacman_key_options=( '--config[Use an alternate config file (instead of /etc/pacman.con)]: :_files' '--gpgdir[Set an alternate directory for GnuPG (instead of /etc/pacman.d/gnupg)]: :_files -/' '--keyserver[Specify a keyserver to use if necessary]' - ) +) _pacman_key() { - case $words[CURRENT] in - --*) - _arguments -s : \ - "$_pacman_key_options[@]" \ - "$_key_longopts[@]" - ;; - -*) - _arguments -s : \ - "$_pacman_key_options[@]" \ - "$_key_shortopts[@]" \ - "$_key_longopts[@]" - ;; - *) - i=$#; - while [[ $words[$i] != -* ]] && [[ $words[$i] != "pacman-key" ]];do - i=$(($i-1)) - done - case $i in - --*) - _arguments -s : \ - "$_pacman_key_options[@]" \ - "$_key_longopts[@]" - ;; - -*) - _arguments -s : \ - "$_pacman_key_options[@]" \ - "$_key_shortopts[@]" \ - "$_key_longopts[@]" - ;; - *) return 1;; - esac - ;; - esac + case $words[CURRENT] in + --*) + _arguments -s : \ + "$_pacman_key_options[@]" \ + "$_key_longopts[@]" + ;; + -*) + _arguments -s : \ + "$_pacman_key_options[@]" \ + "$_key_shortopts[@]" \ + "$_key_longopts[@]" + ;; + *) + i=$#; + while [[ $words[$i] != -* ]] && [[ $words[$i] != "pacman-key" ]];do + i=$(($i-1)) + done + case $i in + --*) + _arguments -s : \ + "$_pacman_key_options[@]" \ + "$_key_longopts[@]" + ;; + -*) + _arguments -s : \ + "$_pacman_key_options[@]" \ + "$_key_shortopts[@]" \ + "$_key_longopts[@]" + ;; + *) + return 1 + ;; + esac + ;; + esac } _keys() { @@ -482,7 +498,7 @@ _makepkg_shortopts=( '*-r[Remove installed dependencies after a successful build]' '*-R[Repackage contents of the package without rebuilding]' '*-S[Generate a source-only tarball without downloading sources]' - ) +) _makepkg_action_none(){ _arguments \ @@ -521,51 +537,61 @@ _makepkg_longopts=( '--noconfirm[do not ask for confirmation when resolving dependencies]' '--asdeps[Install packages as non-explicitly installed]' '--noprogressbar[Do not show a progress bar when downloading files]' - ) +) _makepkg(){ - case $words[CURRENT] in - -*) - _arguments -s -w : \ - "$_makepkg_shortopts[@]" \ - "$_makepkg_longopts[@]" - ;; - --* ) - _arguments -s \ - "$_makepkg_longopts[@]" - ;; - - )_makepkg_action_none ;; - * ) - i=$# - while [[ $words[i] != -* ]] && [[ $words[$i] != "makepkg" ]];do - i=$((i-1)); - done - case $words[$i] in - -*) - _arguments -s -w : \ - "$_makepkg_shortopts[@]" \ - "$_makepkg_longopts[@]" - ;; - --* ) - _arguments -s \ - "$_makepkg_longopts[@]" - ;; - - )_makepkg_action_none ;; - * ) return 1 ;; - esac - ;; - esac + case $words[CURRENT] in + -*) + _arguments -s -w : \ + "$_makepkg_shortopts[@]" \ + "$_makepkg_longopts[@]" + ;; + --* ) + _arguments -s \ + "$_makepkg_longopts[@]" + ;; + - ) + _makepkg_action_none + ;; + *) + i=$# + while [[ $words[i] != -* ]] && [[ $words[$i] != "makepkg" ]];do + i=$((i-1)); + done + case $words[$i] in + -*) + _arguments -s -w : \ + "$_makepkg_shortopts[@]" \ + "$_makepkg_longopts[@]" + ;; + --* ) + _arguments -s \ + "$_makepkg_longopts[@]" + ;; + - ) + _makepkg_action_none + ;; + * ) + return 1 + ;; + esac + ;; + esac } _pacman_comp() { - case "$service" in - makepkg) - _makepkg "$@";; - pacman-key) - _pacman_key "$@";; - pacman) - _pacman_zsh_comp "$@";; - *) - _message "Error";; - esac + case "$service" in + makepkg) + _makepkg "$@" + ;; + pacman-key) + _pacman_key "$@" + ;; + pacman) + _pacman_zsh_comp "$@" + ;; + *) + _message "Error" + ;; + esac } _pacman_comp "$@" -- 1.8.1.5
Signed-off-by: Daniel Wallace <danielwallace@gtmanfred.com> --- contrib/zsh_completion.in | 156 +++++++++++++++++++++++----------------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/contrib/zsh_completion.in b/contrib/zsh_completion.in index 515320c..d5a6e06 100644 --- a/contrib/zsh_completion.in +++ b/contrib/zsh_completion.in @@ -60,7 +60,7 @@ _pacman_opts_query_modifiers=( '-k[Check package files]' '-l[List package contents]' '-m[List installed packages not found in sync db(s)]' - '-n[List installed packages found in sync db(s)]' + '-n[List installed packages found in sync db(s)]' '-t[List packages not required by any package]' '-u[List packages that can be upgraded]' ) @@ -76,8 +76,8 @@ _pacman_opts_remove=( ) _pacman_opts_database=( - '--asdeps[mark packages as non-explicitly installed]' - '--asexplicit[mark packages as explicitly installed]' + '--asdeps[mark packages as non-explicitly installed]' + '--asexplicit[mark packages as explicitly installed]' ) # options for passing to _arguments: options for --sync command @@ -102,9 +102,9 @@ _pacman_opts_sync_modifiers=( '-w[Download packages only]' '-y[Download fresh package databases]' '*--ignore[Ignore a package upgrade]:package: - _pacman_completions_all_packages' + _pacman_completions_all_packages' '*--ignoregroup[Ignore a group upgrade]:package group: - _pacman_completions_all_groups' + _pacman_completions_all_groups' '--asdeps[Install packages as non-explicitly installed]' '--asexplicit[Install packages as explicitly installed]' '--force[Overwrite conflicting files]' @@ -191,7 +191,7 @@ _pacman_action_sync() { "$_pacman_opts_common[@]" \ "$_pacman_opts_sync_modifiers[@]" \ '*-c[Remove old packages from cache]' \ - ;; + ;; sync_group) _arguments -s : \ "$_pacman_opts_common[@]" \ @@ -276,9 +276,9 @@ _pacman_completions_installed_packages() { } _pacman_all_packages() { - _alternative : \ - 'localpkgs:local packages:_pacman_completions_installed_packages' \ - 'repopkgs:repository packages:_pacman_completions_all_packages' + _alternative : \ + 'localpkgs:local packages:_pacman_completions_installed_packages' \ + 'repopkgs:repository packages:_pacman_completions_all_packages' } # provides completions for repository names @@ -383,7 +383,7 @@ _pacman_zsh_comp() { } _key_shortopts=( - '-h[show help]' \ + '-h[show help]' '-a[Add the specified keys (empty for stdin)]: :_files' '-d[Remove the Specified keyids]:*: :_keys' '-e[Export the specified or all keyids]:*: :_keys' @@ -461,82 +461,82 @@ _pacman_key() { } _keys() { - local keylist keys - keylist=$(pacman-key --list-keys 2>/dev/null | awk ' - $1 == "pub" { - # key id - split($2, a, "/"); print a[2] - } - $1 == "uid" { - # email - if (match($NF, /<[^>]+>/)) - print substr($NF, RSTART + 1, RLENGTH - 2) - #this adds support for names as well if that is ever added - } - $1 == "uid" { - for (i=2;i<NF;i++) {printf "%s%s",sep, $i;sep=" "}; printf "\n" - }' |sed -e 's/(.*)//g' -e 's/^\ //g' -e 's/\ *$//g' |uniq - ) - keys=(${(s:/:)${keylist//$'\n'/\/}}) - _describe -t modules 'keys in keyring' keys && return 0 + local keylist keys + keylist=$(pacman-key --list-keys 2>/dev/null | awk ' + $1 == "pub" { + # key id + split($2, a, "/"); print a[2] + } + $1 == "uid" { + # email + if (match($NF, /<[^>]+>/)) + print substr($NF, RSTART + 1, RLENGTH - 2) + #this adds support for names as well if that is ever added + } + $1 == "uid" { + for (i=2;i<NF;i++) {printf "%s%s",sep, $i;sep=" "}; printf "\n" + }' |sed -e 's/(.*)//g' -e 's/^\ //g' -e 's/\ *$//g' |uniq + ) + keys=(${(s:/:)${keylist//$'\n'/\/}}) + _describe -t modules 'keys in keyring' keys && return 0 } _makepkg_shortopts=( - '*-s[Install missing dependencies with pacman]' - '*-i[Install package after successful build]' - '*-A[Ignore incomplete arch field in PKGBUILD]' - '*-c[Clean up work files after build]' - '*-d[Skip all dependency checks]' - '*-e[Do not extract source files (use existing src/ dir)]' - '*-f[Overwrite existing package]' - '*-g[Generate integrity checks for source files]' - '*-h[Show help message and exit]' - '*-L[Log package build process]' - '*-m[Disable colorized output messages]' - '*-o[Download and extract files only]' - '-p[Use an alternate build script (instead of 'PKGBUILD')]: :_files' - '*-r[Remove installed dependencies after a successful build]' - '*-R[Repackage contents of the package without rebuilding]' - '*-S[Generate a source-only tarball without downloading sources]' + '*-s[Install missing dependencies with pacman]' + '*-i[Install package after successful build]' + '*-A[Ignore incomplete arch field in PKGBUILD]' + '*-c[Clean up work files after build]' + '*-d[Skip all dependency checks]' + '*-e[Do not extract source files (use existing src/ dir)]' + '*-f[Overwrite existing package]' + '*-g[Generate integrity checks for source files]' + '*-h[Show help message and exit]' + '*-L[Log package build process]' + '*-m[Disable colorized output messages]' + '*-o[Download and extract files only]' + '-p[Use an alternate build script (instead of 'PKGBUILD')]: :_files' + '*-r[Remove installed dependencies after a successful build]' + '*-R[Repackage contents of the package without rebuilding]' + '*-S[Generate a source-only tarball without downloading sources]' ) _makepkg_action_none(){ - _arguments \ - "$_makepkg_shortopts[@]"\ - "$_makepkg_longopts[@]" + _arguments \ + "$_makepkg_shortopts[@]" \ + "$_makepkg_longopts[@]" } _makepkg_longopts=( - '--ignorearch[Ignore incomplete arch field in PKGBUILD]' - '--clean[Clean up work files after build]' - '--nodeps[Skip all dependency checks]' - '--noextract[Do not extract source files (use existing src/ dir)]' - '--force[Overwrite existing package]' - '--geninteg[Generate integrity checks for source files]' - '--help[Show help message and exit]' - '--install[Install package after successful build]' - '--log[Log package build process]' - '--nocolor[Disable colorized output messages]' - '--nobuild[Download and extract files only]' - '--rmdeps[Remove installed dependencies after a successful build]' - '--repackage[Repackage contents of the package without rebuilding]' - '--syncdeps[Install missing dependencies with pacman]' - '--source[Generate a source-only tarball without downloading sources]' - '--allsource[Generate a source-only tarball including downloaded source]' - '--asroot[Allow makepkg to run as root user]' - '--check[Run check() function in the PKGBUILD]' - '--config[Use an alternate config file instead of '/etc/makepkg.conf']: :_files' - '--holdver[Prevent automatic version bumping for development PKGBUILDs]' - '--key[Specify key to use for gpg signing instead of the default]: :_keys' - '--nocheck[Do not run the check() function in the PKGBUILD]' - '--nosign[Do not create a signature for the package]' - '--pkg[Only build listed packages from a split package]' - '--sign[Sign the resulting package with gpg]' - '--skipchecksums[Do not verify checksums of the source files]' - '--skipinteg[do not perform any verification checks on source files]' - '--skippgpcheck[Do not verify source files with PGP signatures]' - '--noconfirm[do not ask for confirmation when resolving dependencies]' - '--asdeps[Install packages as non-explicitly installed]' - '--noprogressbar[Do not show a progress bar when downloading files]' + '--ignorearch[Ignore incomplete arch field in PKGBUILD]' + '--clean[Clean up work files after build]' + '--nodeps[Skip all dependency checks]' + '--noextract[Do not extract source files (use existing src/ dir)]' + '--force[Overwrite existing package]' + '--geninteg[Generate integrity checks for source files]' + '--help[Show help message and exit]' + '--install[Install package after successful build]' + '--log[Log package build process]' + '--nocolor[Disable colorized output messages]' + '--nobuild[Download and extract files only]' + '--rmdeps[Remove installed dependencies after a successful build]' + '--repackage[Repackage contents of the package without rebuilding]' + '--syncdeps[Install missing dependencies with pacman]' + '--source[Generate a source-only tarball without downloading sources]' + '--allsource[Generate a source-only tarball including downloaded source]' + '--asroot[Allow makepkg to run as root user]' + '--check[Run check() function in the PKGBUILD]' + '--config[Use an alternate config file instead of '/etc/makepkg.conf']: :_files' + '--holdver[Prevent automatic version bumping for development PKGBUILDs]' + '--key[Specify key to use for gpg signing instead of the default]: :_keys' + '--nocheck[Do not run the check() function in the PKGBUILD]' + '--nosign[Do not create a signature for the package]' + '--pkg[Only build listed packages from a split package]' + '--sign[Sign the resulting package with gpg]' + '--skipchecksums[Do not verify checksums of the source files]' + '--skipinteg[do not perform any verification checks on source files]' + '--skippgpcheck[Do not verify source files with PGP signatures]' + '--noconfirm[do not ask for confirmation when resolving dependencies]' + '--asdeps[Install packages as non-explicitly installed]' + '--noprogressbar[Do not show a progress bar when downloading files]' ) _makepkg(){ case $words[CURRENT] in -- 1.8.1.5
On Wed, Mar 06, 2013 at 04:13:43PM -0500, Daniel Wallace wrote:
Signed-off-by: Daniel Wallace <danielwallace@gtmanfred.com>
Tested it on all options and operations. Works much better than before, just one thing that I'm not at all concerned about, `pacman -Sy<tab>` removes `-y` from the list, same with -u. I don't know if it's even worth it to fix that, though. +1 -- William Giokas | KaiSforza GnuPG Key: 0x73CD09CF Fingerprint: F73F 50EF BBE2 9846 8306 E6B8 6902 06D8 73CD 09CF
On 07/03/13 15:09, William Giokas wrote:
On Wed, Mar 06, 2013 at 04:13:43PM -0500, Daniel Wallace wrote:
Signed-off-by: Daniel Wallace <danielwallace@gtmanfred.com>
Tested it on all options and operations. Works much better than before, just one thing that I'm not at all concerned about,
`pacman -Sy<tab>`
removes `-y` from the list, same with -u. I don't know if it's even worth it to fix that, though.
+1
These patches improve the current situation despite this issue. And talking on IRC, it would be best that those issues are addressed in a separate patch. So I am going to pull them as is. It would be good if a bug report was filed about this issue. Allan
On 07/03/13 07:13, Daniel Wallace wrote:
Signed-off-by: Daniel Wallace <danielwallace@gtmanfred.com> --- contrib/zsh_completion.in | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
diff --git a/contrib/zsh_completion.in b/contrib/zsh_completion.in index 84ee93c..a40192c 100644 --- a/contrib/zsh_completion.in +++ b/contrib/zsh_completion.in @@ -6,9 +6,11 @@ typeset -A opt_args
# options for passing to _arguments: main pacman commands _pacman_opts_commands=( + '-D[Modify database]' '-Q[Query the package database]' '-R[Remove a package from the system]' '-S[Synchronize packages]' + '-T[Check if dependencies are installed]' '-U[Upgrade a package]' '-V[Display version and exit]' '-h[Display usage]' @@ -71,6 +73,11 @@ _pacman_opts_remove=( '*:installed package:_pacman_completions_installed_packages' )
+_pacman_opts_database=( + '--asdeps[mark packages as non-explicitly installed]' + '--asexplicit[mark packages as explicitly installed]' +) + # options for passing to _arguments: options for --sync command _pacman_opts_sync_actions=( '*-c[Remove old packages from cache]:*:clean:->sync_clean' @@ -164,6 +171,16 @@ _pacman_action_remove() { "$_pacman_opts_remove[@]" }
+# handles --database subcommand +_pacman_action_database() { + _arguments -s : \ + '-D' \ + "$_pacman_opts_common[@]" \ + "$_pacman_opts_database[@]" +} + + + # handles --sync subcommand _pacman_action_sync() { local context state line @@ -309,6 +326,13 @@ _pacman_zsh_comp() { -Q*) _pacman_action_query ;; -R*) _pacman_action_remove ;; -S*c*) # no completion
Looks like you inserted into the middle of this...
+ -T*) + _arguments -s : \ + '-T' \ + "$_pacman_opts_common[@]" \ + ":packages:_pacman_all_packages" + ;; + -D*) _pacman_action_database ;;
Keep this in alphabetical order like the rest of the file.
return 0 ;; -S*l*) # repos
participants (3)
-
Allan McRae
-
Daniel Wallace
-
William Giokas