]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/rvm/rvm.plugin.zsh
2a091d019e042170d6b10f118107dbc82673c1c5
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / rvm / rvm.plugin.zsh
1 # Completion
2 fpath+=("${rvm_path}/scripts/zsh/Completion")
3
4 typeset -g -A _comps
5 autoload -Uz _rvm
6 _comps[rvm]=_rvm
7
8 # Aliases
9 alias rubies='rvm list rubies'
10 alias rvms='rvm gemset'
11 alias gemsets='rvms list'
12
13
14 # rb{version} utilities
15 # From `rvm list known`
16 typeset -A rubies
17 rubies=(
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 )
31
32 for v in ${(k)rubies}; do
33   version="${rubies[$v]}"
34   functions[rb${v}]="rvm use ${version}\${1+"@\$1"}"
35   functions[_rb${v}]="compadd \$(ls -1 \"\${rvm_path}/gems\" | grep '^${version}@' | sed -e 's/^${version}@//' | awk '{print $1}')"
36   compdef _rb$v rb$v
37 done
38 unset rubies v version
39
40
41 function rvm-update {
42   rvm get head
43 }
44
45 # TODO: Make this usable w/o rvm.
46 function gems {
47   local current_ruby=`rvm-prompt i v p`
48   local current_gemset=`rvm-prompt g`
49
50   gem list $@ | sed -E \
51     -e "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
52     -e "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
53     -e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
54     -e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
55 }