Skip to content

Commit

Permalink
Add rbenv-whence to show you which versions of Ruby have a given command
Browse files Browse the repository at this point in the history
  • Loading branch information
sstephenson committed Aug 3, 2011
1 parent 652135d commit d257b56
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions libexec/rbenv-whence
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash -e

if [ "$1" = "--path" ]; then
print_paths="1"
shift
else
print_paths=""
fi

whence() {
local command="$1"
rbenv-versions --bare | while read version; do
path="$(rbenv-prefix "$version")/bin/${command}"
if [ -x "$path" ]; then
[ "$print_paths" ] && echo "$path" || echo "$version"
fi
done
}

RBENV_COMMAND="$1"
result="$(whence "$RBENV_COMMAND")"
[ -n "$result" ] && echo "$result"

0 comments on commit d257b56

Please sign in to comment.