2011-08-12 05:33:45 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
2011-09-12 11:11:59 -04:00
|
|
|
[ -n "$RBENV_DEBUG" ] && set -x
|
2011-08-10 09:53:24 -04:00
|
|
|
|
|
|
|
print_set_version() {
|
2011-08-10 10:23:43 -04:00
|
|
|
echo "<version> should be a string matching a Ruby version known by rbenv."
|
|
|
|
|
|
|
|
local versions="$(rbenv-versions --bare)"
|
|
|
|
if [ -z "$versions" ]; then
|
|
|
|
echo "There are currently no Ruby versions installed for rbenv."
|
|
|
|
else
|
|
|
|
echo "The currently installed Ruby versions are:"
|
|
|
|
echo "$versions" | sed 's/^/ /'
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "The special version string 'system' will use your default system Ruby."
|
2011-08-10 09:53:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
"") echo "usage: rbenv <command> [<args>]
|
|
|
|
|
|
|
|
Some useful rbenv commands are:
|
2011-09-28 11:48:04 -04:00
|
|
|
commands List all rbenv commands
|
2011-08-10 10:23:43 -04:00
|
|
|
rehash Rehash rbenv shims (run this after installing binaries)
|
2011-08-18 15:32:33 -04:00
|
|
|
global Set or show the global Ruby version
|
2011-08-13 02:50:23 -04:00
|
|
|
local Set or show the local directory-specific Ruby version
|
2011-09-28 11:21:57 -04:00
|
|
|
shell Set or show the shell-specific Ruby version
|
2011-08-10 10:23:43 -04:00
|
|
|
version Show the current Ruby version
|
|
|
|
versions List all Ruby versions known by rbenv
|
2011-09-28 11:48:04 -04:00
|
|
|
which Show the full path for the given Ruby command
|
|
|
|
whence List all Ruby versions with the given command
|
2011-08-10 09:53:24 -04:00
|
|
|
|
2011-09-28 11:59:02 -04:00
|
|
|
See 'rbenv help <command>' for information on a specific command.
|
|
|
|
For full documentation, see: https://github.com/sstephenson/rbenv#readme"
|
2011-08-10 09:53:24 -04:00
|
|
|
;;
|
2011-08-18 15:32:33 -04:00
|
|
|
global) echo "usage: rbenv global <version>
|
2011-08-10 09:53:24 -04:00
|
|
|
|
2011-08-18 15:32:33 -04:00
|
|
|
Sets the global Ruby version. You can override the global version at
|
|
|
|
any time by setting a directory-specific version with \`rbenv local'
|
|
|
|
or by setting the RBENV_VERSION environment variable.
|
2011-08-10 09:53:24 -04:00
|
|
|
|
|
|
|
$(print_set_version)"
|
|
|
|
;;
|
2011-08-13 02:34:15 -04:00
|
|
|
local) echo "usage: rbenv local <version>
|
2011-09-28 11:21:57 -04:00
|
|
|
rbenv local --unset
|
2011-08-10 09:53:24 -04:00
|
|
|
|
2011-08-10 10:23:43 -04:00
|
|
|
Sets the local directory-specific Ruby version by writing the version
|
|
|
|
name to a file named '.rbenv-version'.
|
|
|
|
|
|
|
|
When you run a Ruby command, rbenv will look for an '.rbenv-version'
|
|
|
|
file in the current directory and each parent directory. If no such
|
2011-08-18 15:32:33 -04:00
|
|
|
file is found in the tree, rbenv will use the global Ruby version
|
|
|
|
specified with \`rbenv global', or the version specified in the
|
2011-08-10 10:23:43 -04:00
|
|
|
RBENV_VERSION environment variable.
|
2011-08-10 09:53:24 -04:00
|
|
|
|
2011-09-28 11:21:57 -04:00
|
|
|
$(print_set_version)"
|
|
|
|
;;
|
|
|
|
shell) echo "usage: rbenv shell <version>
|
|
|
|
rbenv shell --unset
|
|
|
|
|
|
|
|
Sets a shell-specific Ruby version by setting the 'RBENV_VERSION'
|
|
|
|
environment variable in your shell. This version overrides both
|
|
|
|
project-specific versions and the global version.
|
|
|
|
|
2011-08-10 09:53:24 -04:00
|
|
|
$(print_set_version)"
|
|
|
|
;;
|
2011-09-28 11:48:04 -04:00
|
|
|
which) echo "usage: rbenv which <command>
|
|
|
|
|
|
|
|
Displays the full path to the binary that rbenv will execute when you
|
|
|
|
run the given command."
|
|
|
|
;;
|
|
|
|
whence) echo "usage: rbenv whence <command>
|
|
|
|
|
|
|
|
Lists all Ruby versions with the given command installed."
|
|
|
|
;;
|
2011-09-28 11:59:02 -04:00
|
|
|
*)
|
|
|
|
command_path="$(command -v "rbenv-$1" || true)"
|
|
|
|
if [ -n "$command_path" ]; then
|
|
|
|
echo "Sorry, the \`$1' command isn't documented yet."
|
|
|
|
echo
|
|
|
|
echo "You can view the command's source here:"
|
|
|
|
echo "$command_path"
|
|
|
|
echo
|
|
|
|
else
|
|
|
|
echo "rbenv: no such command \`$1'"
|
|
|
|
fi
|
2011-08-10 09:53:24 -04:00
|
|
|
esac
|