rvm.plugin.zsh
1254 bytes
1# Completion
2fpath+=("${rvm_path}/scripts/zsh/Completion")
3
4typeset -g -A _comps
5autoload -Uz _rvm
6_comps[rvm]=_rvm
7
8# Aliases
9alias rubies='rvm list rubies'
10alias rvms='rvm gemset'
11alias gemsets='rvms list'
12
13
14# rb{version} utilities
15# From `rvm list known`
16typeset -A rubies
17rubies=(
18 18 'ruby-1.8.7'
19 19 'ruby-1.9.3'
20 20 'ruby-2.0.0'
21 21 'ruby-2.1'
22 22 'ruby-2.2'
23 23 'ruby-2.3'
24 24 'ruby-2.4'
25 25 'ruby-2.5'
26 26 'ruby-2.6'
27 27 'ruby-2.7'
28 30 'ruby-3.0'
29 31 'ruby-3.1'
30 32 'ruby-3.2'
31)
32
33for v in ${(k)rubies}; do
34 version="${rubies[$v]}"
35 functions[rb${v}]="rvm use ${version}\${1+"@\$1"}"
36 functions[_rb${v}]="compadd \$(ls -1 \"\${rvm_path}/gems\" | grep '^${version}@' | sed -e 's/^${version}@//' | awk '{print $1}')"
37 compdef _rb$v rb$v
38done
39unset rubies v version
40
41
42function rvm-update {
43 rvm get head
44}
45
46# TODO: Make this usable w/o rvm.
47function gems {
48 local current_ruby=`rvm-prompt i v p`
49 local current_gemset=`rvm-prompt g`
50
51 gem list $@ | sed -E \
52 -e "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
53 -e "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
54 -e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
55 -e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
56}