Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 119 lines (99 sloc) 4.837 kB
e8081d1 @nicoulaj #29: Add rvm completion
nicoulaj authored
1 #compdef rvm
2 # ------------------------------------------------------------------------------
3 # Description
4 # -----------
5 #
6 # Completion script for rvm (https://rvm.beginrescueend.com/).
7 #
8 # Source: https://github.com/wayneeseguin/rvm/blob/master/scripts/zsh/Completion/_rvm
9 #
10 # ------------------------------------------------------------------------------
11 # Authors
12 # -------
13 #
14 # * Bruno Michel (https://github.com/nono)
15 #
16 # ------------------------------------------------------------------------------
17 # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
18 # vim: ft=zsh sw=2 ts=2 et
19 # ------------------------------------------------------------------------------
20
21
22 local curcontext="$curcontext" state line cmds ret=1
23
24 _arguments -C \
25 '(- 1 *)'{-v,--version}'[display version information]' \
26 '(-l|--level)'{-l,--level}'+[patch level to use with rvm use / install]:number' \
27 '(--prefix)--prefix[path for all rvm files (~/.rvm/), with trailing slash!]:path:_files' \
28 '(--bin)--bin[path for binaries to be placed (~/.rvm/bin/)]:path:_files' \
29 '(--source)--source[src directory to use (~/.rvm/src/)]:path:_files' \
30 '(--archives)--archives[directory for downladed files (~/.rvm/archives/)]:path:_files' \
31 '-S[Specify a script file to attempt to load and run (rubydo)]:file:_files' \
32 '-e[Execute code from the command line]:code' \
33 '(-G)-G[root gem path to use]:path:_files' \
34 '(--gems)--gems[Used to set the gems_flag, use with remove to remove gems]' \
35 '(--archive)--archive[Used to set the archive_flag, use with remove to remove archive]' \
36 '(--patch)--patch[With MRI Rubies you may specify one or more full paths to patches]' \
37 '(-C|--configure)'{-C,--configure}'=[custom configure options]' \
38 '(--nice)--nice[process niceness (for slow computers, default 0)]:number' \
39 '(--ree)--ree-options[Options passed directly to ree ./installer on the command line]:options' \
40 '(--head)--head[with update, updates rvm to git head version]' \
41 '(--rubygems)--rubygems[with update, updates rubygems for selected ruby]' \
42 '(--default)--default[with ruby select, sets a default ruby for new shells]' \
43 '(--debug)--debug[Toggle debug mode on for very verbose output]' \
44 '(--trace)--trace[Toggle trace mode on to see EVERYTHING rvm is doing]' \
45 '(--force)--force[Force install, removes old install & source before install]' \
46 '(--summary)--summary[Used with rubydo to print out a summary of the commands run]' \
47 '(--latest)--latest[with gemset --dump skips version strings for latest gem]' \
48 '(--gems)--gems[with uninstall/remove removes gems with the interpreter]' \
49 '(--docs)--docs[with install, attempt to generate ri after installation]' \
50 '(--reconfigure)--reconfigure[Force ./configure on install even if Makefile already exists]' \
51 '1: :->cmds' \
52 '*: :->args' && ret=0
53
54 case $state in
55
56 cmds)
57
58 cmds=( ${(f)"$(_call_program commands rvm help 2> /dev/null | sed -e '/^== Action/,/^== Implementation/!d; / - /!d; s/^[ *]*\([^ ]*\) *\- *\(.*\)/\1:\2/')"} )
59 cmds+=( $(rvm list strings) )
60 _describe -t commands 'rvm command' cmds && ret=0
61 ;;
62
63 args)
64
65 case $line[1] in
66
67 (use|uninstall|remove|list)
68
69 if (( CURRENT == 3 )); then
70 # See if we’ve made it to the ‘@’; eg, 1.9.2@
71 if ! \grep -q '@' <<< "${line[CURRENT-1]}" ; then
72 _values -S , 'rubies' \
73 $(rvm list strings | sed -e 's/ruby-\([^) ]*\)-\([^) ]*\)/ruby-\1-\2 \1-\2 \1/g') \
74 default system $(rvm alias list | cut -d' ' -f1) && ret=0
75 else
76 # Construct a full version string for each of the gemsets.
77 # Eg, 1.9.2@min 1.9.2@rail3 …
78 _values -S , 'gemsets' \
79 $(rvm ${line[CURRENT-1]%%@*} gemset list | awk '/^[ -_[:alnum:]]+$/ {print "'${line[CURRENT-1]%%@*}'@"$1}')
80 fi
81 fi
82 ;;
83
84 (install|fetch)
85
86 _values -S , 'rubies' $(rvm list known_strings) && ret=0
87 ;;
88
89 gemset)
90
91 if (( CURRENT == 3 )); then
92 _values 'gemset_commands' $(rvm gemset | sed -e '/create/!d; s/^.*[{]\(.*\)[}].*$/\1/; s/,/ /g')
93 else
94 #_values -S , 'gemsets' $(rvm gemset list | \grep -v gemset 2>/dev/null)
95 _values -S , 'gemsets' $(rvm gemset list | \grep -Ev '(gemset|info)' 2>/dev/null | awk '/^[ -_[:alnum:]]+$/ {print '$1'}')
96 fi
97 ret=0
98 ;;
99
100 package)
101
102 if (( CURRENT == 3 )); then
103 _values 'package_commands' $(rvm package | sed -e '/Usage/!d; s/^.*[{]\(.*\)[}] [{].*$/\1/; s/,/ /g')
104 else
105 _values 'packages' $(rvm package | sed -e '/Usage/!d; s/^.*[}] [{]\(.*\)[}].*$/\1/; s/,/ /g')
106 fi
107 ret=0
108 ;;
109
110 *)
111 (( ret )) && _message 'no more arguments'
112 ;;
113
114 esac
115 ;;
116 esac
117
118 return ret
Something went wrong with that request. Please try again.