Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add zsh completion

  • Loading branch information...
commit 9533cb1a212845072c7c09d790ee2e5655fbeef9 1 parent 4487d27
@eregon eregon authored
Showing with 48 additions and 0 deletions.
  1. +1 −0  Makefile
  2. +1 −0  bin/ry
  3. +46 −0 lib/ry.zsh_completion
View
1  Makefile
@@ -7,3 +7,4 @@ install:
install -d $(PREFIX)/bin $(PREFIX)/lib
install -C -m 0755 ./bin/ry $(PREFIX)/bin/ry
install -C -m 0644 ./lib/ry.bash_completion $(PREFIX)/lib/ry.bash_completion
+ install -C -m 0644 ./lib/ry.zsh_completion $(PREFIX)/lib/ry.zsh_completion
View
1  bin/ry
@@ -83,6 +83,7 @@ ry::setup() {
cat <<sh
export PATH="$(ry fullpath "$@")";
if [ -n "\$BASH_VERSION" ]; then . "$RY_PREFIX/lib/ry.bash_completion"; fi
+if [ -n "\$ZSH_VERSION" ]; then . "$RY_PREFIX/lib/ry.zsh_completion"; fi
sh
}
View
46 lib/ry.zsh_completion
@@ -0,0 +1,46 @@
+_ry() {
+ local -a rubies
+ if (( CURRENT > 2 )); then
+ shift words
+ (( CURRENT-- ))
+ subcmd="$words[1]"
+
+ case $subcmd in
+ setup|use|remove|rm|exec|binpath|fullpath)
+ 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'
+ )
+ rubies=($(_call_program rubies ry ls))
+ _describe commands commands
+ _describe rubies rubies
+ fi
+}
+
+compdef _ry ry
Please sign in to comment.
Something went wrong with that request. Please try again.