2021-12-29 05:09:11 +08:00
|
|
|
# Completion
|
|
|
|
fpath+=("${rvm_path}/scripts/zsh/Completion")
|
2012-11-19 16:04:10 +08:00
|
|
|
|
2022-01-05 16:10:32 +08:00
|
|
|
typeset -g -A _comps
|
2021-12-29 05:09:11 +08:00
|
|
|
autoload -Uz _rvm
|
|
|
|
_comps[rvm]=_rvm
|
|
|
|
|
|
|
|
# Aliases
|
2011-05-28 22:23:06 +08:00
|
|
|
alias rubies='rvm list rubies'
|
2021-12-18 08:14:14 +08:00
|
|
|
alias rvms='rvm gemset'
|
|
|
|
alias gemsets='rvms list'
|
2011-05-28 22:23:06 +08:00
|
|
|
|
2011-05-28 22:16:06 +08:00
|
|
|
|
2021-12-29 05:09:11 +08:00
|
|
|
# rb{version} utilities
|
|
|
|
# From `rvm list known`
|
|
|
|
typeset -A rubies
|
|
|
|
rubies=(
|
|
|
|
18 'ruby-1.8.7'
|
|
|
|
19 'ruby-1.9.3'
|
|
|
|
20 'ruby-2.0.0'
|
|
|
|
21 'ruby-2.1'
|
|
|
|
22 'ruby-2.2'
|
|
|
|
23 'ruby-2.3'
|
|
|
|
24 'ruby-2.4'
|
|
|
|
25 'ruby-2.5'
|
|
|
|
26 'ruby-2.6'
|
|
|
|
27 'ruby-2.7'
|
|
|
|
30 'ruby-3.0'
|
2022-03-07 17:58:18 +08:00
|
|
|
31 'ruby-3.1'
|
2023-03-01 18:23:32 +08:00
|
|
|
32 'ruby-3.2'
|
2021-12-29 05:09:11 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
for v in ${(k)rubies}; do
|
|
|
|
version="${rubies[$v]}"
|
|
|
|
functions[rb${v}]="rvm use ${version}\${1+"@\$1"}"
|
|
|
|
functions[_rb${v}]="compadd \$(ls -1 \"\${rvm_path}/gems\" | grep '^${version}@' | sed -e 's/^${version}@//' | awk '{print $1}')"
|
|
|
|
compdef _rb$v rb$v
|
|
|
|
done
|
|
|
|
unset rubies v version
|
2011-05-28 22:16:06 +08:00
|
|
|
|
2021-12-29 04:41:08 +08:00
|
|
|
|
2011-05-28 22:35:54 +08:00
|
|
|
function rvm-update {
|
2021-12-29 05:09:11 +08:00
|
|
|
rvm get head
|
2011-05-28 22:35:54 +08:00
|
|
|
}
|
|
|
|
|
2011-05-28 22:50:06 +08:00
|
|
|
# TODO: Make this usable w/o rvm.
|
|
|
|
function gems {
|
2021-12-29 05:09:11 +08:00
|
|
|
local current_ruby=`rvm-prompt i v p`
|
|
|
|
local current_gemset=`rvm-prompt g`
|
2012-09-03 11:51:28 +08:00
|
|
|
|
2021-12-29 05:09:11 +08:00
|
|
|
gem list $@ | sed -E \
|
|
|
|
-e "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
|
|
|
|
-e "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
|
|
|
|
-e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
|
|
|
|
-e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
|
2012-09-03 11:51:28 +08:00
|
|
|
}
|