Merge branch 'master' of https://github.com/zsh-users/zsh-completions
This commit is contained in:
		
						commit
						7ecc156ef7
					
				
							
								
								
									
										26
									
								
								src/_brew
								
								
								
								
							
							
						
						
									
										26
									
								
								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 | ||||
| 
 | ||||
|  |  | |||
|  | @ -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 | ||||
							
								
								
									
										36
									
								
								src/_gem
								
								
								
								
							
							
						
						
									
										36
									
								
								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 | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										34
									
								
								src/_heroku
								
								
								
								
							
							
						
						
									
										34
									
								
								src/_heroku
								
								
								
								
							|  | @ -162,9 +162,41 @@ 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]:remote:->remotes' \ | ||||
|   &&  return 0 | ||||
| 
 | ||||
| __heroku_git_remotes () { | ||||
| 	local expl gitdir remotes | ||||
| 
 | ||||
| 	gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null) | ||||
| 	__heroku_git_command_successful || return | ||||
| 
 | ||||
| 	remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]}) | ||||
| 	__heroku_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 | ||||
| } | ||||
| 
 | ||||
| __heroku_git_command_successful () { | ||||
| 	if (( ${#pipestatus:#0} > 0 )); then | ||||
| 		_message 'not a git repository' | ||||
| 		return 1 | ||||
| 	fi | ||||
| 	return 0 | ||||
| } | ||||
| 
 | ||||
| case $state in | ||||
|   (remotes) | ||||
|    __heroku_git_remotes && return 0 | ||||
|   ;; | ||||
| esac | ||||
| 
 | ||||
| # Local Variables: | ||||
| # mode: Shell-Script | ||||
| # sh-indentation: 2 | ||||
|  |  | |||
|  | @ -0,0 +1,70 @@ | |||
| #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 | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| # 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 | ||||
| 
 | ||||
|  | @ -0,0 +1,116 @@ | |||
| #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 | ||||
| 
 | ||||
|     local showfiles='' | ||||
|     (( CURRENT <= 2 )) && showfiles='!' | ||||
| 
 | ||||
|     # 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)]' \ | ||||
|         $showfiles'*: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 "$@" | ||||
							
								
								
									
										225
									
								
								src/_port
								
								
								
								
							
							
						
						
									
										225
									
								
								src/_port
								
								
								
								
							|  | @ -11,92 +11,155 @@ | |||
| # | ||||
| #  * Matt Cable <wozz@wookie.net> | ||||
| #  * Sorin Ionescu <sorin.ionescu@gmail.com> | ||||
| #  * Aljaž Srebrnič <a2piratesoft@gmail.com> | ||||
| # | ||||
| # ------------------------------------------------------------------------------ | ||||
| 
 | ||||
| local subcmds | ||||
| _port() { | ||||
|   # Variables for _argument | ||||
|   typeset -A opt_args | ||||
|   local   context state state_descr line | ||||
| 
 | ||||
| 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' | ||||
| ) | ||||
|   local   actions pseudo_common pseudo_advanced select_options port_prefix | ||||
| 
 | ||||
| _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 | ||||
|   port_prefix=$(which port | sed 's|/bin/port||') | ||||
| 
 | ||||
| case "$state" in | ||||
| 	(command) | ||||
|   	if (( CURRENT == 1 )); then | ||||
|   		state='subcommands' | ||||
|   	else | ||||
|   		state='portname' | ||||
|   	fi | ||||
| 	;; | ||||
| esac | ||||
|   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 ) | ||||
| 
 | ||||
| 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 | ||||
|   pseudo_common=(all current active inactive actinact installed uninstalled outdated | ||||
|   obsolete requested unrequested leaves) | ||||
| 
 | ||||
|   	_describe -t commands 'available ports' _port_list | ||||
| 	;; | ||||
| esac | ||||
|   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)' | ||||
|   ) | ||||
| 
 | ||||
|   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 | ||||
|     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)]' \ | ||||
|     '-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) | ||||
|       _port_dispatch | ||||
|       ;; | ||||
|   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 | ||||
|       ;; | ||||
|     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 ) && | ||||
|         ! _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_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 "$@" | ||||
|  |  | |||
|  | @ -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 | ||||
| 
 | ||||
		Loading…
	
		Reference in New Issue