-
Notifications
You must be signed in to change notification settings - Fork 13
/
ry.zsh_completion
49 lines (46 loc) · 1.45 KB
/
ry.zsh_completion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#compdef ry
# ry ZSH completion function
# Symlink (or copy) this file in your $fpath (like /usr/share/zsh/site-functions)
# and name it _ry: ln -s path/to/this/file _ry
local -a rubies
if (( CURRENT > 2 )); then
shift words
(( CURRENT-- ))
local subcmd="$words[1]"
case $subcmd in
setup|use|remove|rm|exec|binpath|fullpath|system)
rubies=($(_call_program rubies ry ls))
;;
install)
if (( $+commands[ruby-build] )); then
rubies=($(_call_program rubies ruby-build --definitions))
fi
;;
*)
rubies=()
;;
esac
_describe rubies rubies
else
local -a commands
# usage is not listed so "use" completes directly
commands=(
version:'show ry version'
help:'show the help'
current:'show the current ruby name'
setup:'setup ry (with an optional ruby as an argument)'
ls:'output the installed rubies'
rubies:'output the installed rubies, and highlight the current one'
use:'use the given ruby'
install:'install the given ruby-build recipe'
remove:'remove the given rubies'
rm:'remove the given rubies'
exec:'execute a command in the context of each comma-separated ruby'
binpath:'print the bin directory for the given ruby'
fullpath:'print a modified version of $PATH that exclusively includes the given ruby'
system:'fallback to the default system version'
)
rubies=($(_call_program rubies ry ls))
_describe commands commands
_describe rubies rubies
fi