From 4ed58553175dd8d4491ba4c7f56b1c2399f41d69 Mon Sep 17 00:00:00 2001 From: Paulo L F Casaretto Date: Tue, 12 Mar 2013 23:23:40 -0300 Subject: [PATCH 01/23] Add 'remote' argument to heroku Also add the shorter -a switch to the app argument --- src/_heroku | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/_heroku b/src/_heroku index 820cfe1..6794299 100644 --- a/src/_heroku +++ b/src/_heroku @@ -162,7 +162,8 @@ case "$words[1]" in _arguments \ $_command_args \ - '(--app)--app[the app name]' \ + '(-a|--app)'{-a,--app}'[the app name]' \ + '(-r|--remote)'{-r,--remote}'[the git remote name]' \ && return 0 # Local Variables: From d5674edf4492408418ea240fc5056449fa9d792d Mon Sep 17 00:00:00 2001 From: Paulo L F Casaretto Date: Wed, 13 Mar 2013 13:47:23 -0300 Subject: [PATCH 02/23] Add remote argument completions This was copied from _git-flow --- src/_heroku | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/_heroku b/src/_heroku index 6794299..b9a8967 100644 --- a/src/_heroku +++ b/src/_heroku @@ -163,9 +163,40 @@ case "$words[1]" in _arguments \ $_command_args \ '(-a|--app)'{-a,--app}'[the app name]' \ - '(-r|--remote)'{-r,--remote}'[the git remote name]' \ + '(-r|--remote)'{-r,--remote}'[the git remote name]:remote:->remotes' \ && return 0 +__git_remotes () { + local expl gitdir remotes + + gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null) + __git_command_successful || return + + remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]}) + __git_command_successful || return + + # TODO: Should combine the two instead of either or. + if (( $#remotes > 0 )); then + _wanted remotes expl remote compadd $* - $remotes + else + _wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*" + fi +} + +__git_command_successful () { + if (( ${#pipestatus:#0} > 0 )); then + _message 'not a git repository' + return 1 + fi + return 0 +} + +case $state in + (remotes) + __git_remotes && return 0 + ;; +esac + # Local Variables: # mode: Shell-Script # sh-indentation: 2 From 6483c0c3a13d9feb9bb2a1cb3db8b430c35e4669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aljaz=CC=8C=20=22g5pw=22=20Srebrnic=CC=8C?= Date: Wed, 20 Mar 2013 08:22:38 +0100 Subject: [PATCH 03/23] Overhauled port command completion Port command completion got smarter. It can now complete paths for the provides subcommand, and complete pseudo-portnames. It will complete all ports or only installed ones (for example, when completing for the uninstall command). It will complete the select subcommand with appropriate values. --- src/_port | 190 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 109 insertions(+), 81 deletions(-) diff --git a/src/_port b/src/_port index 9053f53..db39c1f 100644 --- a/src/_port +++ b/src/_port @@ -11,92 +11,120 @@ # # * Matt Cable # * Sorin Ionescu +# * Aljaž Srebrnič # # ------------------------------------------------------------------------------ -local subcmds +_port_select() { + if (( CURRENT == 3 )); then + _describe 'Port select options' select_options + elif (( CURRENT == 4 )); then + local select_group + select_group=() + for f in $port_prefix/etc/select/*; do + select_group+=$(basename $f) + done + _describe "Port select groups" select_group + elif [[ $CURRENT -eq 5 && $words[3] == '--set' ]]; then + local select_variants + select_variants=("${(f)$(port select --list $words[4] | sed -e '1 d' -e 's/^[ \t]*//' -e 's/ (active)$//')}") + _describe "Port select group $words[4] variants" select_variants + fi +} -subcmds=( - 'activate' - 'archive' - 'build' - 'cat' - 'clean' - 'configure' - 'contents' - 'deactivate' - 'dependents' - 'deps' - 'destroot' - 'dir' - 'distcheck' - 'distclean' - 'dmg' - 'echo' - 'edit' - 'extract' - 'fetch' - 'file' - 'help' - 'info' - 'install' - 'installed' - 'list' - 'livecheck' - 'location' - 'mpkg' - 'outdated' - 'patch' - 'pkg' - 'provides' - 'rpmpackage' - 'search' - 'selfupdate' - 'sync' - 'test' - 'unarchive' - 'uninstall' - 'upgrade' - 'variants' - 'version' -) +_port() { + # Variables for _argument + typeset -A opt_args + local context state state_descr line -_arguments -C \ - '-v[verbose mode (generate verbose messages)]' \ - '-d[debug mode (generate debugging messages)]' \ - '-q[quiet mode (suppress messages)]' \ - '-D[specify portdir]' \ - '-k[keep mode (do not autoclean after install)]' \ - '-n[dont follow dependencies in upgrade (only for upgrading)]' \ - '-a[upgrade all installed ports (only for upgrading)]' \ - '-u[uninstall non-active ports when upgrading and uninstalling]' \ - '-f[force mode (ignore state file)]' \ - '-s[source-only mode]' \ - '-b[binary-only mode]' \ - '-o[honor state files older than Portfile]' \ - '*::command:->command' \ - && return 0 + local actions pseudo_common pseudo_advanced select_options port_prefix -case "$state" in - (command) - if (( CURRENT == 1 )); then - state='subcommands' - else - state='portname' - fi - ;; -esac + port_prefix=$(which port | sed 's|/bin/port||') -case "$state" in - (subcommands) - _describe -t commands 'port commands' subcmds - ;; - (portname) - # Cache the list of ports. - if (( ! $+_port_list )); then - _port_list=($(port echo all; echo "all current active inactive installed uninstalled outdated")) - fi + actions=( activate archive archivefetch build cat cd + checksum clean configure contents deactivate dependents deps + destroot dir distcheck distfiles dmg dpkg echo edit exit + extract fetch file gohome help info install installed lint list + livecheck load location log logfile mdmg mirror mpkg notes + outdated patch pkg platform portpkg provides quit rdependents + rdeps rev-upgrade rpm search select selfupdate setrequested space + srpm submit sync test unarchive uninstall unload unsetrequested + upgrade url usage variants version work ) - _describe -t commands 'available ports' _port_list - ;; -esac + pseudo_common=(all current active inactive actinact installed uninstalled outdated + obsolete requested unrequested leaves) + + pseudo_advanced=('variants:' 'variant:' 'description:' 'depends:' + 'depends_lib:' 'depends_run:' 'depends_build:' 'depends_fetch:' 'depends_extract:' + 'portdir:' 'homepage:' 'epoch:' 'platforms:' 'platform:' 'name:' 'long_description:' + 'maintainers:' 'maintainer:' 'categories:' 'category:' 'version:' 'revision:' 'license:') + + select_options=( + '--list:List available versions for the group' + '--set:Select the given version for the group' + '--show:Show which version is currently selected for the group \(default if none given\)' + ) + + _arguments -s -C \ + '-v[verbose mode (generate verbose messages)]' \ + '-d[debug mode (generate debugging messages, implies -v)]' \ + '-q[quiet mode (suppress messages)]' \ + "-n[don't upgrade dependencies (affects upgrade and install)]" \ + "-R[also upgrade dependents (only affects upgrade) - note that this does not upgrade dependents' dependencies]" \ + '-u[uninstall non-active ports when upgrading and uninstalling]' \ + '-f[force mode (ignore state file)]' \ + '-o[honor state files even if the Portfile has been modified since (called -o because it used to mean "older")]' \ + '-s[source-only mode (build and install from source, do not attempt to fetch binary archives)]' \ + '-b[binary-only mode (build and install from binary archives, ignore source, abort if no archive available)]' \ + '-c[autoclean mode (execute clean after install)]' \ + "-k[keep mode (don't autoclean after install)]" \ + '-D[specify portdir]' \ + '-F[Read and process the file of commands specified by the argument.]' \ + '-p[Despite any errors encountered, proceed to process multiple ports and commands.]' \ + '-y[Perform a dry run.]' \ + '-t[enable trace mode debug facilities on platforms that support it (Mac OS X).]' \ + "1:Port actions:($actions)" \ + '*:extra:->extra' \ + && return 0 + + case "$state" in + extra) + case "$words[2]" in + provides) + _files + ;; + search) + _guard '^--*' 'pattern' + ;; + help) + _describe -t actions 'Port actions' actions + ;; + select) + _call_function - _port_select + ;; + contents|deactivate|setrequested|space|uninstall|unsetrequested) + # Cache the list of all ports. + if (( ! $+_installed_ports )); then + _installed_ports=$(_call_program path-installed "port installed | cut -d ' ' -f 3") + fi + _alternative \ + "ports:Installed ports:($_installed_ports)" \ + "pseudo-common:Common Pseudo-portnames:($pseudo_common)" \ + "pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)" + ;; + *) + # Cache the list of all ports. + if (( ! $+_all_ports )); then + _all_ports=$(_call_program path-all "port echo all") + fi + _alternative \ + "ports:Available ports:($_all_ports)" \ + "pseudo-common:Common Pseudo-portnames:($pseudo_common)" \ + "pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)" + ;; + esac + ;; + esac +} + +_port "$@" From 2224f3ae7191010126d0d56d55453d072b9604ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aljaz=CC=8C=20=22g5pw=22=20Srebrnic=CC=8C?= Date: Sun, 24 Mar 2013 22:26:32 +0100 Subject: [PATCH 04/23] Moved port_select function to bottom --- src/_port | 67 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/src/_port b/src/_port index db39c1f..064928a 100644 --- a/src/_port +++ b/src/_port @@ -15,23 +15,6 @@ # # ------------------------------------------------------------------------------ -_port_select() { - if (( CURRENT == 3 )); then - _describe 'Port select options' select_options - elif (( CURRENT == 4 )); then - local select_group - select_group=() - for f in $port_prefix/etc/select/*; do - select_group+=$(basename $f) - done - _describe "Port select groups" select_group - elif [[ $CURRENT -eq 5 && $words[3] == '--set' ]]; then - local select_variants - select_variants=("${(f)$(port select --list $words[4] | sed -e '1 d' -e 's/^[ \t]*//' -e 's/ (active)$//')}") - _describe "Port select group $words[4] variants" select_variants - fi -} - _port() { # Variables for _argument typeset -A opt_args @@ -87,6 +70,12 @@ _port() { '*:extra:->extra' \ && return 0 + local cache_policy + zstyle -s ":completion:${curcontext}:" cache-policy cache_policy + if [[ -z "$cache_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _port_caching_policy + fi + case "$state" in extra) case "$words[2]" in @@ -103,22 +92,28 @@ _port() { _call_function - _port_select ;; contents|deactivate|setrequested|space|uninstall|unsetrequested) - # Cache the list of all ports. - if (( ! $+_installed_ports )); then - _installed_ports=$(_call_program path-installed "port installed | cut -d ' ' -f 3") + # Cache the list of installed ports. + if ( [[ ${+_port_installed_packages} -eq 0 ]] || _cache_invalid PORT_INSTALLED_PACKAGES ) && + ! _retrieve_cache PORT_INSTALLED_PACKAGES; + then + _port_installed_packages=( $(_call_program path-all "port echo all") ) + _store_cache PORT_INSTALLED_PACKAGES _port_installed_packages fi _alternative \ - "ports:Installed ports:($_installed_ports)" \ + "ports:Installed ports:($_port_installed_packages)" \ "pseudo-common:Common Pseudo-portnames:($pseudo_common)" \ "pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)" ;; *) # Cache the list of all ports. - if (( ! $+_all_ports )); then - _all_ports=$(_call_program path-all "port echo all") + if ( [[ ${+_port_available_packages} -eq 0 ]] || _cache_invalid PORT_AVAILABLE_PACKAGES ) && + ! _retrieve_cache PORT_AVAILABLE_PACKAGES; + then + _port_available_packages=( $(_call_program path-all "port echo all") ) + _store_cache PORT_AVAILABLE_PACKAGES _port_available_packages fi _alternative \ - "ports:Available ports:($_all_ports)" \ + "ports:Available ports:($_port_available_packages)" \ "pseudo-common:Common Pseudo-portnames:($pseudo_common)" \ "pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)" ;; @@ -127,4 +122,28 @@ _port() { esac } +_port_select() { + if (( CURRENT == 3 )); then + _describe 'Port select options' select_options + elif (( CURRENT == 4 )); then + local select_group + select_group=() + for f in $port_prefix/etc/select/*; do + select_group+=$(basename $f) + done + _describe "Port select groups" select_group + elif [[ $CURRENT -eq 5 && $words[3] == '--set' ]]; then + local select_variants + select_variants=("${(f)$(port select --list $words[4] | sed -e '1 d' -e 's/^[ \t]*//' -e 's/ (active)$//')}") + _describe "Port select group $words[4] variants" select_variants + fi +} + +_port_caching_policy() { + local reg_time comp_time + reg_time=$(stat -c '%Z' $port_prefix/var/macports/registry/registry.db) + comp_time=$(stat -c '%Z' $1) + return $(( reg_time < comp_time )) +} + _port "$@" From d8a2e94fa0ca36f89fccc1ef3750bc3bfe331060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aljaz=CC=8C=20=22g5pw=22=20Srebrnic=CC=8C?= Date: Sun, 24 Mar 2013 22:28:20 +0100 Subject: [PATCH 05/23] Use native caching system --- src/_port | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/_port b/src/_port index 064928a..11e91dd 100644 --- a/src/_port +++ b/src/_port @@ -70,12 +70,6 @@ _port() { '*:extra:->extra' \ && return 0 - local cache_policy - zstyle -s ":completion:${curcontext}:" cache-policy cache_policy - if [[ -z "$cache_policy" ]]; then - zstyle ":completion:${curcontext}:" cache-policy _port_caching_policy - fi - case "$state" in extra) case "$words[2]" in @@ -139,11 +133,4 @@ _port_select() { fi } -_port_caching_policy() { - local reg_time comp_time - reg_time=$(stat -c '%Z' $port_prefix/var/macports/registry/registry.db) - comp_time=$(stat -c '%Z' $1) - return $(( reg_time < comp_time )) -} - _port "$@" From f2cff3dbf37504945a586f364112a41dfb7060c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aljaz=CC=8C=20=22g5pw=22=20Srebrnic=CC=8C?= Date: Sun, 24 Mar 2013 22:31:08 +0100 Subject: [PATCH 06/23] Use own cache policy This checks modification dates of the repository database and completion cache and refreshes the latter if it is older than the database. --- src/_port | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/_port b/src/_port index 11e91dd..064928a 100644 --- a/src/_port +++ b/src/_port @@ -70,6 +70,12 @@ _port() { '*:extra:->extra' \ && return 0 + local cache_policy + zstyle -s ":completion:${curcontext}:" cache-policy cache_policy + if [[ -z "$cache_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _port_caching_policy + fi + case "$state" in extra) case "$words[2]" in @@ -133,4 +139,11 @@ _port_select() { fi } +_port_caching_policy() { + local reg_time comp_time + reg_time=$(stat -c '%Z' $port_prefix/var/macports/registry/registry.db) + comp_time=$(stat -c '%Z' $1) + return $(( reg_time < comp_time )) +} + _port "$@" From 2b9822ef8f808d9739f6d1d1b4f699d9479ad000 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sun, 31 Mar 2013 15:35:54 +0200 Subject: [PATCH 07/23] _dzen2: initial commit --- src/_dzen2 | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/_dzen2 diff --git a/src/_dzen2 b/src/_dzen2 new file mode 100644 index 0000000..d543e4e --- /dev/null +++ b/src/_dzen2 @@ -0,0 +1,44 @@ +#compdef dzen2 + +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for dzen2 0.8.5 ( https://github.com/robm/dzen ) +# Last updated: 31.03.2013 +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Valodim ( https://github.com/Valodim ) +# +# ------------------------------------------------------------------------------ +# Notes +# ----- +# +# the _x_color completer has rather outdated paths, a zstyle like this helps +# get the x colors right (the list is rather long, then) +# +# zstyle ":completion:*:colors" path '/etc/X11/rgb.txt' +# +# ------------------------------------------------------------------------------ + +_arguments \ + '-fg[Set foreground color]:foreground color:_x_color' \ + '-bg[Set background color]:background color:_x_color' \ + '-fn[Set font]:font:_x_font' \ + '-ta[Set alignement of title window content]:alignment:( l c r )' \ + '-tw[Set title window width]:width (pixels)' \ + '-sa[Set alignment of slave window]:alignment:( l c r )' \ + '-l[Number of lines to display in slave window]:lines' \ + '-e[Set up events and actions]:event string' \ + '-m[Start up in menu mode]' \ + '-u[Update contents of title and slave window simultaneously]' \ + '-p[Persist EOF]:timeout (seconds)' \ + '-x[Set x position on the screen]:x position (pixels)' \ + '-y[Set y position on the screen]:y position (pixels)' \ + '-h[Set line height]:line height (pixels)' \ + '-w[Set window width]:width (pixels)' \ + '-xs[Set the Xinerama screen number where dzen should appear]:screen number' \ + '-v[Display version information]' && return 0 From ef8d5806c445d100e877c4f9c0210d9ba769aca4 Mon Sep 17 00:00:00 2001 From: Mark Cornick Date: Sat, 23 Mar 2013 10:20:43 -0400 Subject: [PATCH 08/23] Add completion for knife user commands These commands were added in Chef 11.0.0. --- src/_knife | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/_knife b/src/_knife index 8d51d99..be55e56 100644 --- a/src/_knife +++ b/src/_knife @@ -44,7 +44,7 @@ _knife() { case $state in knifecmd) - compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" environment exec index node recipe role search ssh status windows $cloudproviders + compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" environment user exec index node recipe role search ssh status windows $cloudproviders ;; knifesubcmd) case $words[2] in @@ -63,6 +63,9 @@ _knife() { environment) compadd -Q "$@" create delete edit "from file" list show ;; + user) + compadd -Q "$@" create delete edit list reregister show + ;; node) compadd -Q "$@" "from file" create show edit delete list run_list "bulk delete" ;; @@ -186,6 +189,10 @@ _chef_environments_remote() { (knife environment list | awk '{print $1}') } +_chef_users_remote() { + (knife user list | awk '{print $1}') +} + # The chef_x_local functions use the knife config to find the paths of relevant objects x to be uploaded to the server _chef_cookbooks_local() { (for i in $( grep cookbook_path $HOME/.chef/knife.rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/' ); do ls $i; done) From 4aa41e226780725bf50e4f273834d0923ba8c4e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aljaz=CC=8C=20=22g5pw=22=20Srebrnic=CC=8C?= Date: Sun, 31 Mar 2013 22:49:15 +0200 Subject: [PATCH 09/23] Use message instead of guard Use _message instead of _guard when completing the search pattern. --- src/_port | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_port b/src/_port index 064928a..806dd41 100644 --- a/src/_port +++ b/src/_port @@ -83,7 +83,7 @@ _port() { _files ;; search) - _guard '^--*' 'pattern' + _message 'pattern' ;; help) _describe -t actions 'Port actions' actions From 11685635242e5d49fd76c1fff96d93247e2de462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aljaz=CC=8C=20=22g5pw=22=20Srebrnic=CC=8C?= Date: Sun, 31 Mar 2013 22:52:26 +0200 Subject: [PATCH 10/23] _port: add upgrade completions Port upgrade completes only outdated ports. --- src/_port | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/_port b/src/_port index 806dd41..a028075 100644 --- a/src/_port +++ b/src/_port @@ -104,6 +104,11 @@ _port() { "pseudo-common:Common Pseudo-portnames:($pseudo_common)" \ "pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)" ;; + upgrade) + local outdated_packages + outdated_packages=("${(f)$(port outdated | sed -e '1 d' -e 's/^\([[:graph:]]*\).*/\1/')}") + _describe "Outdated ports" outdated_packages + ;; *) # Cache the list of all ports. if ( [[ ${+_port_available_packages} -eq 0 ]] || _cache_invalid PORT_AVAILABLE_PACKAGES ) && From 810840e0e045be40822d5c27092e44bfdd5190c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aljaz=CC=8C=20=22g5pw=22=20Srebrnic=CC=8C?= Date: Sun, 31 Mar 2013 23:29:55 +0200 Subject: [PATCH 11/23] Remove unnecessary parenthesis escaping --- src/_port | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_port b/src/_port index a028075..ab36f2d 100644 --- a/src/_port +++ b/src/_port @@ -45,7 +45,7 @@ _port() { select_options=( '--list:List available versions for the group' '--set:Select the given version for the group' - '--show:Show which version is currently selected for the group \(default if none given\)' + '--show:Show which version is currently selected for the group (default if none given)' ) _arguments -s -C \ From 54ed122d25dab95cacc2defb2d5601121bf1075a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aljaz=CC=8C=20=22g5pw=22=20Srebrnic=CC=8C?= Date: Sun, 31 Mar 2013 23:29:55 +0200 Subject: [PATCH 12/23] Set cache-policy before calling _arguments --- src/_port | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/_port b/src/_port index ab36f2d..177691f 100644 --- a/src/_port +++ b/src/_port @@ -48,6 +48,12 @@ _port() { '--show:Show which version is currently selected for the group (default if none given)' ) + local cache_policy + zstyle -s ":completion:${curcontext}:" cache-policy cache_policy + if [[ -z "$cache_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _port_caching_policy + fi + _arguments -s -C \ '-v[verbose mode (generate verbose messages)]' \ '-d[debug mode (generate debugging messages, implies -v)]' \ @@ -70,12 +76,6 @@ _port() { '*:extra:->extra' \ && return 0 - local cache_policy - zstyle -s ":completion:${curcontext}:" cache-policy cache_policy - if [[ -z "$cache_policy" ]]; then - zstyle ":completion:${curcontext}:" cache-policy _port_caching_policy - fi - case "$state" in extra) case "$words[2]" in From 3e6040e01d2f5c3fec4834adedac5b26551b5687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aljaz=CC=8C=20=22g5pw=22=20Srebrnic=CC=8C?= Date: Sun, 31 Mar 2013 23:29:55 +0200 Subject: [PATCH 13/23] Do not use state mechanism Call a dispatch function instead, simplifying the nested select case. --- src/_port | 94 +++++++++++++++++++++++++++---------------------------- 1 file changed, 46 insertions(+), 48 deletions(-) diff --git a/src/_port b/src/_port index 177691f..f1d64ff 100644 --- a/src/_port +++ b/src/_port @@ -73,56 +73,54 @@ _port() { '-y[Perform a dry run.]' \ '-t[enable trace mode debug facilities on platforms that support it (Mac OS X).]' \ "1:Port actions:($actions)" \ - '*:extra:->extra' \ + '*:extra:_port_dispatch' \ && return 0 +} - case "$state" in - extra) - case "$words[2]" in - provides) - _files - ;; - search) - _message 'pattern' - ;; - help) - _describe -t actions 'Port actions' actions - ;; - select) - _call_function - _port_select - ;; - contents|deactivate|setrequested|space|uninstall|unsetrequested) - # Cache the list of installed ports. - if ( [[ ${+_port_installed_packages} -eq 0 ]] || _cache_invalid PORT_INSTALLED_PACKAGES ) && - ! _retrieve_cache PORT_INSTALLED_PACKAGES; - then - _port_installed_packages=( $(_call_program path-all "port echo all") ) - _store_cache PORT_INSTALLED_PACKAGES _port_installed_packages - fi - _alternative \ - "ports:Installed ports:($_port_installed_packages)" \ - "pseudo-common:Common Pseudo-portnames:($pseudo_common)" \ - "pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)" - ;; - upgrade) - local outdated_packages - outdated_packages=("${(f)$(port outdated | sed -e '1 d' -e 's/^\([[:graph:]]*\).*/\1/')}") - _describe "Outdated ports" outdated_packages - ;; - *) - # Cache the list of all ports. - if ( [[ ${+_port_available_packages} -eq 0 ]] || _cache_invalid PORT_AVAILABLE_PACKAGES ) && - ! _retrieve_cache PORT_AVAILABLE_PACKAGES; - then - _port_available_packages=( $(_call_program path-all "port echo all") ) - _store_cache PORT_AVAILABLE_PACKAGES _port_available_packages - fi - _alternative \ - "ports:Available ports:($_port_available_packages)" \ - "pseudo-common:Common Pseudo-portnames:($pseudo_common)" \ - "pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)" - ;; - esac +_port_dispatch() { + case "$words[2]" in + provides) + _files + ;; + search) + _message 'pattern' + ;; + help) + _describe -t actions 'Port actions' actions + ;; + select) + _call_function - _port_select + ;; + contents|deactivate|setrequested|space|uninstall|unsetrequested) + # Cache the list of installed ports. + if ( [[ ${+_port_installed_packages} -eq 0 ]] || _cache_invalid PORT_INSTALLED_PACKAGES ) && + ! _retrieve_cache PORT_INSTALLED_PACKAGES; + then + _port_installed_packages=( $(_call_program path-all "port echo all") ) + _store_cache PORT_INSTALLED_PACKAGES _port_installed_packages + fi + _alternative \ + "ports:Installed ports:($_port_installed_packages)" \ + "pseudo-common:Common Pseudo-portnames:($pseudo_common)" \ + "pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)" + ;; + upgrade) + local outdated_packages + outdated_packages=("${(f)$(port outdated | sed -e '1 d' -e 's/^\([[:graph:]]*\).*/\1/')}") + _describe "Outdated ports" outdated_packages + ;; + *) + # Cache the list of all ports. + if ( [[ ${+_port_available_packages} -eq 0 ]] || _cache_invalid PORT_AVAILABLE_PACKAGES ) && + ! _retrieve_cache PORT_AVAILABLE_PACKAGES; + then + _port_available_packages=( $(_call_program path-all "port echo all") ) + _store_cache PORT_AVAILABLE_PACKAGES _port_available_packages + fi + _alternative \ + "ports:Available ports:($_port_available_packages)" \ + "pseudo-common:Common Pseudo-portnames:($pseudo_common)" \ + "pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)" ;; esac } From 7b412ed1bae9d1e06180f2003b5b421f2b17eb0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aljaz=CC=8C=20=22g5pw=22=20Srebrnic=CC=8C?= Date: Tue, 2 Apr 2013 21:41:40 +0200 Subject: [PATCH 14/23] Fix bug introduced in 3e6040e01 I can't call a function from _arguments --- src/_port | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/_port b/src/_port index f1d64ff..859d21a 100644 --- a/src/_port +++ b/src/_port @@ -73,8 +73,14 @@ _port() { '-y[Perform a dry run.]' \ '-t[enable trace mode debug facilities on platforms that support it (Mac OS X).]' \ "1:Port actions:($actions)" \ - '*:extra:_port_dispatch' \ + '*:extra:->extra' \ && return 0 + + case "$state" in + extra) + _port_dispatch + ;; + esac } _port_dispatch() { From 8d9cdfc58911ffc0d8b7591d6e47976d47398f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aljaz=CC=8C=20=22g5pw=22=20Srebrnic=CC=8C?= Date: Tue, 2 Apr 2013 21:56:07 +0200 Subject: [PATCH 15/23] Add completion for rev-upgrade subcommand --- src/_port | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/_port b/src/_port index 859d21a..173eb4f 100644 --- a/src/_port +++ b/src/_port @@ -48,6 +48,8 @@ _port() { '--show:Show which version is currently selected for the group (default if none given)' ) + revupgrade_options=('--id-loadcmd-check:Run more checks against a special loadcommand in Mach-O binaries') + local cache_policy zstyle -s ":completion:${curcontext}:" cache-policy cache_policy if [[ -z "$cache_policy" ]]; then @@ -115,6 +117,11 @@ _port_dispatch() { outdated_packages=("${(f)$(port outdated | sed -e '1 d' -e 's/^\([[:graph:]]*\).*/\1/')}") _describe "Outdated ports" outdated_packages ;; + rev-upgrade) + if (( CURRENT == 3 )); then + _describe 'Rev-upgrade options' revupgrade_options + fi + ;; *) # Cache the list of all ports. if ( [[ ${+_port_available_packages} -eq 0 ]] || _cache_invalid PORT_AVAILABLE_PACKAGES ) && From 513546f59f9cc24e9ac86ff9d85c6b48f18d4e5a Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Wed, 3 Apr 2013 01:27:02 +0200 Subject: [PATCH 16/23] _id3: initial commit --- src/_id3 | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/_id3 diff --git a/src/_id3 b/src/_id3 new file mode 100644 index 0000000..9438466 --- /dev/null +++ b/src/_id3 @@ -0,0 +1,64 @@ +#compdef id3 + +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for id3, based on v0.15 +# +# Last updated: 03.04.2013 +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Valodim ( https://github.com/Valodim ) +# +# ------------------------------------------------------------------------------ + +_id3_genre () { + + setopt localoptions extendedglob + + local -A _id3_genres + # got them cached? + if _cache_invalid id3-genres || ! _retrieve_cache id3-genres ; then + + # generate from id3 -L otherwise + local tmp + for line in ${${${(f)"$(_call_program id3genre id3 -L)"}## #}}; do + tmp=( ${(s,: ,)line} ) + _id3_genres[${tmp[1]}]=$tmp[2] + # alternate display string, which I decided against in the end + # to preserve reasonable alphabetic sorting + # "${(l:3:: :)${tmp[1]}}: ${tmp[2]}" + done + + # store if we got any + (( $#_id3_genres > 0 )) && _store_cache id3-genres _id3_genres + fi + + # bail if we don't + (( $#_id3_genres > 0 )) || { _message "could not fetch genres"; return } + + _wanted id3genres expl 'Genres' \ + compadd -d _id3_genres -k _id3_genres && return 0 + +} + +_arguments \ + '-t[Modifies a Title tag]:title' \ + '-T[Modifies a Track tag]:track' \ + '-a[Modifies an Artist tag]:artist' \ + '-A[Modifies an Album tag]:album' \ + '-y[Modifies a Year tag]:year' \ + '-c[Modifies a Comment tag]:comment' \ + '-g[Modifies a Genre tag]:genre:_id3_genre' \ + '(-)-l[Lists an ID3 tag]' \ + '-R[Uses an rfc822-style format for output]' \ + '(-)-d[Deletes an ID3 tag]' \ + '(- *)-L[Lists all genres]' \ + '(- *)-h[Displays this help info]' \ + '(- *)-v[Prints version info]' \ + '*:mp3 file:_files -g \*.mp3' && return 0 + From 6c0e222b0c94453dedeff8be67f89add128120c9 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 6 Apr 2013 22:51:04 +0200 Subject: [PATCH 17/23] _id3v2: initial commit --- src/_id3v2 | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 src/_id3v2 diff --git a/src/_id3v2 b/src/_id3v2 new file mode 100644 index 0000000..160c757 --- /dev/null +++ b/src/_id3v2 @@ -0,0 +1,113 @@ +#compdef id3v2 + +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for id3v2, based on v0.1.12 +# +# Last updated: 05.04.2013 +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Valodim ( https://github.com/Valodim ) +# +# ------------------------------------------------------------------------------ + +_id3v2_genre () { + + setopt localoptions extendedglob + + local -A _id3v2_genres + # got them cached? + if _cache_invalid id3v2-genres || ! _retrieve_cache id3v2-genres ; then + + # generate from id3 -L otherwise + local tmp + for line in ${${${(f)"$(_call_program id3v2genres id3v2 -L)"}## #}}; do + tmp=( ${(s,: ,)line} ) + _id3v2_genres[${tmp[1]}]=$tmp[2] + # alternate display string, which I decided against in the end + # to preserve reasonable alphabetic sorting + # "${(l:3:: :)${tmp[1]}}: ${tmp[2]}" + done + + # store if we got any + (( $#_id3v2_genres > 0 )) && _store_cache id3v2-genres _id3v2_genres + fi + + # bail if we don't + (( $#_id3v2_genres > 0 )) || { _message "could not fetch genres"; return } + + _wanted id3v2genres expl 'Genres' \ + compadd -d _id3v2_genres -k _id3v2_genres && return 0 + +} + +# this function assumes _id3v2_frames is defined! +_id3v2_frame () { + + (( $#_id3v2_frames > 0 )) || { _message "could not fetch genres"; return } + local -a framenames + framenames=( ${_id3v2_frames#--} ) + _describe -t framenames 'id3v2 frames' framenames + +} + +_id3v2 () { + + setopt localoptions extendedglob + + # previous word was a frame name? this is an argument, then. + if [[ $words[$CURRENT-1] == --[A-Z](#c4) ]]; then + _message 'frame value' + return 0 + fi + + # load frame names + local -a _id3v2_frames + if _cache_invalid id3v2-frames || ! _retrieve_cache id3v2-frames ; then + _id3v2_frames=( ${${${(f)"$(_call_program id3v2frames id3v2 -f)"}## #}/ /:} ) + (( $#_id3v2_frames > 0 )) && _store_cache id3v2-frames _id3v2_frames + fi + + local ret=1 + + # if we already have a -- prefix, show all those frames + if [[ -prefix -- ]] && (( $#_id3v2_frames > 0 )); then + _describe -t frames 'id3v2 frames' _id3v2_frames && ret=0 + fi + + # regular arguments either way + _arguments \ + - tagging \ + '(-s --delete-v1 -d --delete-v2)'{-s,--delete-v1}'[deletes id3v1 tags]' \ + '(-s --delete-v1 -d --delete-v2)'{-d,--delete-v2}'[deletes id3v2 tags]' \ + '(-C --convert)'{-C,--convert}'[converts id3v1 tag to id3v2]' \ + '(-1 --id3v1-only -2 --id3v2-only)'{-1,--id3v1-only}'[write only id3v1 tag]' \ + '(-1 --id3v1-only -2 --id3v2-only)'{-2,--id3v2-only}'[write only id3v2 tag]' \ + '(-r --remove-frame)'{-r,--remove-frame}'[removes specified id3v2 frame]:frame id:_id3v2_frame' \ + '(-a --artist)'{-a,--artist}'[set artist]:artist' \ + '(-A --album)'{-A,--album}'[set album title]:album' \ + '(-t --song)'{-t,--song}'[set song title]:song title' \ + '(-c --comment)'{-c,--comment}'[set comment field]' \ + '(-g --genre)'{-g,--genre}'[set the genre number]:genre:_id3v2_genre' \ + '(-y --year)'{-y,--year}'[set the year]:year' \ + '(-T --track)'{-T,--track}'[set the track number/(optional) total tracks]:track number (current/total)' \ + '(-R --list-rfc822)'{-R,--list-rfc822}'[lists using an rfc822-style format for output]' \ + '(-)'{-D,--delete-all}'[deletes both id3v1 and id3v2 tags]' \ + '(-)'{-l,--list}'[lists the tag(s) on the file(s)]' \ + '*:mp3 file:_files -g "*.mp3"' \ + - meta \ + '(- *)'{-f,--list-frames}'[display all possible frames for id3v2]' \ + '(- *)'{-L,--list-genres}'[lists all id3v1 genres]' \ + '(- *)'{-h,--help}'[display help and exit]' \ + '(- *)'{-v,--version}'[display version information and exit]' && ret=0 + + return ret + +} + +_id3v2 "$@" From 590ba19ead0aa30e63ebd90e3788ae3013f87112 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 6 Apr 2013 22:58:24 +0200 Subject: [PATCH 18/23] _id3: small update in descriptions and logic use present tense. also, complete at least one option before filenames, calling id3 with just file arguments is not a valid operation. --- src/_id3 | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/_id3 b/src/_id3 index 9438466..df4f1de 100644 --- a/src/_id3 +++ b/src/_id3 @@ -46,19 +46,25 @@ _id3_genre () { } -_arguments \ - '-t[Modifies a Title tag]:title' \ - '-T[Modifies a Track tag]:track' \ - '-a[Modifies an Artist tag]:artist' \ - '-A[Modifies an Album tag]:album' \ - '-y[Modifies a Year tag]:year' \ - '-c[Modifies a Comment tag]:comment' \ - '-g[Modifies a Genre tag]:genre:_id3_genre' \ - '(-)-l[Lists an ID3 tag]' \ - '-R[Uses an rfc822-style format for output]' \ - '(-)-d[Deletes an ID3 tag]' \ - '(- *)-L[Lists all genres]' \ - '(- *)-h[Displays this help info]' \ - '(- *)-v[Prints version info]' \ - '*:mp3 file:_files -g \*.mp3' && return 0 +# only show files if at least one argument or something has been provided +local showfiles='' +(( CURRENT <= 2 )) && showfiles='!' + +_arguments \ + - tagging \ + '-t[modify title tag]:title' \ + '-T[modify track tag]:track' \ + '-a[modify artist tag]:artist' \ + '-A[modify album tag]:album' \ + '-y[modify year tag]:year' \ + '-c[modify comment tag]:comment' \ + '-g[modify genre tag]:genre:_id3_genre' \ + '(-)-l[lists tags]' \ + '-R[use rfc822-style format for output]' \ + '(-)-d[delete id3 tag]' \ + $showfiles'*:mp3 file:_files -g \*.mp3' \ + - meta \ + '(- *)-L[list all genres]' \ + '(- *)-h[display help info]' \ + '(- *)-v[print version info]' && return 0 From 7f739d0f1bd97ce51d7d4295983792c2ff7c70b8 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 6 Apr 2013 23:02:35 +0200 Subject: [PATCH 19/23] _id3v2: complete at least one option before filenames --- src/_id3v2 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/_id3v2 b/src/_id3v2 index 160c757..edae6e7 100644 --- a/src/_id3v2 +++ b/src/_id3v2 @@ -80,6 +80,9 @@ _id3v2 () { _describe -t frames 'id3v2 frames' _id3v2_frames && ret=0 fi + local showfiles='' + (( CURRENT <= 2 )) && showfiles='!' + # regular arguments either way _arguments \ - tagging \ @@ -99,7 +102,7 @@ _id3v2 () { '(-R --list-rfc822)'{-R,--list-rfc822}'[lists using an rfc822-style format for output]' \ '(-)'{-D,--delete-all}'[deletes both id3v1 and id3v2 tags]' \ '(-)'{-l,--list}'[lists the tag(s) on the file(s)]' \ - '*:mp3 file:_files -g "*.mp3"' \ + $showfiles'*:mp3 file:_files -g "*.mp3"' \ - meta \ '(- *)'{-f,--list-frames}'[display all possible frames for id3v2]' \ '(- *)'{-L,--list-genres}'[lists all id3v1 genres]' \ From 4fc0541ad1cc84e934ee7dc8bd18b137512dec18 Mon Sep 17 00:00:00 2001 From: mollifier Date: Wed, 10 Apr 2013 06:20:10 +0900 Subject: [PATCH 20/23] Add svm(Scala Version Manager) completion. --- src/_svm | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 src/_svm diff --git a/src/_svm b/src/_svm new file mode 100644 index 0000000..d778f34 --- /dev/null +++ b/src/_svm @@ -0,0 +1,169 @@ +#compdef svm +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for svm (https://github.com/yuroyoro/svm) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Hideaki Miyake (https://github.com/mollifier) +# +# ------------------------------------------------------------------------------ + +local context curcontext="$curcontext" state line ret=1 +typeset -A opt_args + + +local -a _1st_arguments +_1st_arguments=( + 'help:show this usage information' + 'current:show the currently use scala version' + "list:show the scala version installed in svm_path(default is ${HOME}/.svm)" + "versions:show the available scala version not installed" + 'install:install specific scala version' + 'remove:uninstall specific scala version and remove their sources' + 'switch:setup to use a specific scala version' + 'update-latest:install or update nightly build scala version' + 'latest:setup to use nightly build scala version' + 'stable:setup to use stable(x.x.x.final) scala version' +) + +_arguments -C \ + '(-)-h[show this usage information]' \ + '-c[show the currently use scala version]' \ + "-l[show the scala version installed in svm_path(default is ${HOME}/.svm)]" \ + '-v[show the abalabe scala version not installed]' \ + '-i[install specific scala version]: :_svm_completion_not_installed_scala_versions' \ + '-r[uninstall specific scala version and remove their sources]: :_svm_completion_installed_scala_versions' \ + '(-s -u)'{-s,-u}'[setup to use a specific scala version]: :_svm_completion_not_selected_scala_versions' \ + '1: :->cmds' \ + '*:: :->args' && ret=0 + + +# installed scala versions +(( $+functions[_svm_completion_installed_scala_versions] )) || +_svm_completion_installed_scala_versions() { + local -a _installed_versions + _current_version="${$(_call_program installed svm current)#currently version is[[:space:]]*}" + + # collect lines starts with digit + _installed_versions=( ${(M)${(@f)"$(_call_program installed svm list)"}:#[[:digit:]]*} ) + + _describe -t installed "installed versions" _installed_versions +} + +# installed and not selected scala versions +(( $+functions[_svm_completion_not_selected_scala_versions] )) || +_svm_completion_not_selected_scala_versions() { + local _current_version + local -a _not_selected_versions + + _current_version="${$(_call_program installed svm current)#currently version is[[:space:]]*}" + + # collect lines starts with digit + _not_selected_versions=( ${(M)${(@f)"$(_call_program installed svm list)"}:#[[:digit:]]*} ) + + # remove current version + _not_selected_versions=( ${_not_selected_versions:#$_current_version}) + _describe -t installed "not selected versions" _not_selected_versions +} + +# not installed scala versions +(( $+functions[_svm_completion_not_installed_scala_versions] )) || +_svm_completion_not_installed_scala_versions() { + local -a _not_installed_versions + # collect lines starts with digit + _not_installed_versions=( ${(M)${(@f)"$(_call_program installed svm versions)"}:#[[:digit:]]*} ) + + _describe -t notinstalled "not installed versions" _not_installed_versions +} + + +case $state in + cmds) + # action + case $PREFIX in + u*) + # complete command synonyms + local -a _synonym_arguments + _synonym_arguments=( + 'uninstall:uninstall specific scala version and remove their sources' + 'use:setup to use a specific scala version' + 'update-latest:install or update nightly build scala version' + ) + _describe -t actions 'svm actions' _synonym_arguments && ret=0 + ;; + + *) + _describe -t actions 'svm actions' _1st_arguments + _svm_completion_not_selected_scala_versions && ret=0 + ;; + esac + ;; # end action + + args) + # scala version number + case $words[1] in + install) + # install not installed version + _arguments \ + '1: :_svm_completion_not_installed_scala_versions' \ + '--docs[with install, update-latest download scala-devel-docs.]' \ + '--sources[with install, update-latest download scala-sources.]' && ret=0 + ;; + + remove|uninstall) + # remove installed version + _arguments \ + '1: :_svm_completion_installed_scala_versions' && ret=0 + ;; + + switch|use) + # use installed version + _arguments \ + '1: :_svm_completion_not_selected_scala_versions' && ret=0 + ;; + + esac + + ;; # end args +esac + +return ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et + From 3ebbd136dfe9e91d67321d707072f0f033ded500 Mon Sep 17 00:00:00 2001 From: Zhao Cai Date: Thu, 11 Apr 2013 11:33:42 -0400 Subject: [PATCH 21/23] _brew update 1. use _call_program 2. formulae completion for search 3. formulae completion for upgrade 4. add pin/unpin command --- src/_brew | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/_brew b/src/_brew index 4c81d0b..37a95e5 100644 --- a/src/_brew +++ b/src/_brew @@ -23,11 +23,15 @@ _brew_all_formulae() { - formulae=(`brew search`) # FIXME _call_program should be used here + formulae=(${(f)"$(_call_program formulae brew search 2>/dev/null)"}) } _brew_installed_formulae() { - installed_formulae=(`brew list`) # FIXME _call_program should be used here + installed_formulae=(${(f)"$(_call_program formulae brew list 2>/dev/null)"}) +} + +_brew_outdated_formulae() { + outdated_formulae=(${(f)"$(_call_program formulae brew outdated 2>/dev/null)"}) } local -a _1st_arguments @@ -58,6 +62,7 @@ _1st_arguments=( 'test:a few formulae provide a test method' 'unlink:unlink a formula' 'untap:remove a tapped repository' + 'unpin:unpin specified formulae' 'update:freshen up links' 'upgrade:upgrade outdated formulae' 'uses:show formulae which depend on a formula' @@ -65,7 +70,7 @@ _1st_arguments=( ) local expl -local -a formulae installed_formulae +local -a formulae installed_formulae outdated_formulae _arguments \ '(-v)-v[verbose]' \ @@ -87,10 +92,17 @@ case "$words[1]" in search|-S) _arguments \ '(--macports)--macports[search the macports repository]' \ - '(--fink)--fink[search the fink repository]' ;; + '(--fink)--fink[search the fink repository]' \ + '1: :->forms' && return 0 + + if [[ "$state" == forms ]]; then + _brew_all_formulae + _wanted formulae expl 'all formulae' compadd -a formulae + fi ;; list|ls) _arguments \ '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \ + '(--pinned)--pinned[list all versions of pinned formulae]' \ '(--versions)--versions[list all installed versions of a formula]' \ '1: :->forms' && return 0 @@ -101,9 +113,12 @@ case "$words[1]" in install|home|homepage|log|info|abv|uses|cat|deps|edit|options) _brew_all_formulae _wanted formulae expl 'all formulae' compadd -a formulae ;; - remove|rm|uninstall|unlink|cleanup|link|ln|test) + remove|rm|uninstall|unlink|cleanup|link|ln|pin|unpin|test) _brew_installed_formulae _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;; + upgrade) + _brew_outdated_formulae + _wanted outdated_formulae expl 'outdated formulae' compadd -a outdated_formulae ;; esac # Local Variables: @@ -113,3 +128,4 @@ esac # sh-basic-offset: 2 # End: # vim: ft=zsh sw=2 ts=2 et + From 779b6020b6559f1c3bf7213025ed88a29d9e4f38 Mon Sep 17 00:00:00 2001 From: Paulo L F Casaretto Date: Thu, 11 Apr 2013 14:18:51 -0300 Subject: [PATCH 22/23] Namespace git commands under heroku --- src/_heroku | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/_heroku b/src/_heroku index b9a8967..853ea9c 100644 --- a/src/_heroku +++ b/src/_heroku @@ -166,14 +166,14 @@ _arguments \ '(-r|--remote)'{-r,--remote}'[the git remote name]:remote:->remotes' \ && return 0 -__git_remotes () { +__heroku_git_remotes () { local expl gitdir remotes gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null) - __git_command_successful || return + __heroku_git_command_successful || return remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]}) - __git_command_successful || return + __heroku_git_command_successful || return # TODO: Should combine the two instead of either or. if (( $#remotes > 0 )); then @@ -183,7 +183,7 @@ __git_remotes () { fi } -__git_command_successful () { +__heroku_git_command_successful () { if (( ${#pipestatus:#0} > 0 )); then _message 'not a git repository' return 1 @@ -193,7 +193,7 @@ __git_command_successful () { case $state in (remotes) - __git_remotes && return 0 + __heroku_git_remotes && return 0 ;; esac From 7e021224702b924e62f4d2e64a1381d58ff08eff Mon Sep 17 00:00:00 2001 From: Zhao Cai Date: Thu, 11 Apr 2013 17:39:32 -0400 Subject: [PATCH 23/23] _gem: update for browse, edit and clone commands --- src/_gem | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/_gem b/src/_gem index f3d4bf8..505c0e4 100644 --- a/src/_gem +++ b/src/_gem @@ -1,4 +1,4 @@ -#compdef gem gem1.9 +#compdef gem gem1.9 macgem # ------------------------------------------------------------------------------ # Description # ----------- @@ -28,10 +28,29 @@ _gem() { $nul_arg ) + extra_gems=$(_call_program commands ${words[1]} list --no-version gem-browse gemedit gem-edit) + + local gem_edit_command="edit[Edit installed gem in editor]" + local gem_clone_command="clone[Clone a gem's source from GitHub]" + local gem_browse_command="browse[browse the gem's homepage]" + + if [ ${#extra_gems} -eq 0 ] ; then + extra_gem_commands_desc="" + extra_gem_commands="" + elif [[ "${extra_gems[(i)gem-browse]}" -le ${#extra_gems} ]] ; then + extra_gem_commands_desc=(${gem_edit_command} ${gem_browse_command} ${gem_clone_command}) + extra_gem_commands=(clone browse edit) + + elif [[ "${extra_gems[(r)gem-edit]}" -le ${#extra_gems} ]] \ + || [[ "${extra_gems[(r)gemedit]}" -le ${#extra_gems} ]] ; then + extra_gem_commands_desc=${gem_edit_command} + extra_gem_commands=edit + fi + if (( CURRENT > 2 )); then (( CURRENT-- )) shift words - _call_function 1 _gem_${words[1]} + _call_function - _gem_${words[1]} else _values "gem command" \ "build[Build a gem from a gemspec]" \ @@ -40,6 +59,7 @@ _gem() { "cleanup[Clean up old versions of installed gems in the local repository]" \ "contents[Display the contents of the installed gems]" \ "dependency[Show the dependencies of an installed gem]" \ + ${extra_gem_commands_desc} \ "environment[Display information about the RubyGems environment]" \ "fetch[Download a gem and place it in the current directory]" \ "generate_index[Generates the index files for a gem server directory]" \ @@ -84,6 +104,7 @@ __gem_help_arguments() { "cleanup" "contents" "dependency" + $(extra_gem_commands) "environment" "fetch" "generate_index" @@ -179,6 +200,16 @@ _gem_dependency() { "(-p --pipe)"{-p,--pipe}"[Pipe Format (name --version ver)]" \ $gem_general_flags && ret=0 } +_gem_edit() { + _arguments \ + "*:gemname:__all_gems" \ + "(-e --editor)"{-e,--editor}"[GEMEDITOR, BUNDLER_EDITOR, VISUAL and EDITOR environment variables are used to by default]" \ + $gem_general_flags && ret=0 +} + +_gem_browse() { + _gem_edit +} _gem_environment() { typeset -g _environment_arg= @@ -469,3 +500,4 @@ _gem_which() { # sh-basic-offset: 2 # End: # vim: ft=zsh sw=2 ts=2 et +