mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-14 20:39:55 -05:00
Merge branch 'system'
This commit is contained in:
commit
7ce04a6e03
5 changed files with 79 additions and 1 deletions
29
completions/rbenv.bash
Normal file
29
completions/rbenv.bash
Normal file
|
@ -0,0 +1,29 @@
|
|||
_rbenv_commands() {
|
||||
COMPREPLY=()
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
COMPREPLY=( $( compgen -W "$(rbenv commands)" -- $cur ) )
|
||||
}
|
||||
|
||||
_rbenv_versions() {
|
||||
COMPREPLY=()
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
local versions="$(echo system; rbenv versions --bare)"
|
||||
COMPREPLY=( $( compgen -W "$versions" -- $cur ) )
|
||||
}
|
||||
|
||||
_rbenv() {
|
||||
COMPREPLY=()
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
case "$prev" in
|
||||
set-* | prefix )
|
||||
_rbenv_versions
|
||||
;;
|
||||
* )
|
||||
_rbenv_commands
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F _rbenv rbenv
|
11
libexec/rbenv-commands
Executable file
11
libexec/rbenv-commands
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash -e
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
{ for path in ${PATH//:/$'\n'}; do
|
||||
for command in "${path}/rbenv-"*; do
|
||||
echo "${command##*rbenv-}"
|
||||
done
|
||||
done
|
||||
} | sort | uniq
|
||||
|
|
@ -6,6 +6,12 @@ elif [ -z "$RBENV_VERSION" ]; then
|
|||
RBENV_VERSION="$(rbenv-version)"
|
||||
fi
|
||||
|
||||
if [ "$RBENV_VERSION" = "system" ]; then
|
||||
RUBY_PATH="$(rbenv-which ruby)"
|
||||
echo "${RUBY_PATH%/*}"
|
||||
exit
|
||||
fi
|
||||
|
||||
RBENV_PREFIX_PATH="${HOME}/.rbenv/versions/${RBENV_VERSION}"
|
||||
if [ ! -d "$RBENV_PREFIX_PATH" ]; then
|
||||
echo "rbenv: version \`${RBENV_VERSION}' not installed" >&2
|
||||
|
|
|
@ -36,6 +36,11 @@ if [ -z "$RBENV_VERSION" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
if [ "$RBENV_VERSION" = "system" ]; then
|
||||
echo "$RBENV_VERSION"
|
||||
exit
|
||||
fi
|
||||
|
||||
RBENV_VERSION_PATH="${HOME}/.rbenv/versions/${RBENV_VERSION}"
|
||||
|
||||
if [ -d "$RBENV_VERSION_PATH" ]; then
|
||||
|
|
|
@ -1,8 +1,35 @@
|
|||
#!/usr/bin/env bash -e
|
||||
|
||||
expand_path() {
|
||||
local cwd="$(pwd)"
|
||||
cd "$1"
|
||||
pwd
|
||||
cd "$cwd"
|
||||
}
|
||||
|
||||
remove_from_path() {
|
||||
local path_to_remove="$(expand_path "$1")"
|
||||
local result=""
|
||||
|
||||
for path in ${PATH//:/$'\n'}; do
|
||||
path="$(expand_path "$path" || true)"
|
||||
if [ "$path" != "$path_to_remove" ]; then
|
||||
result="${result}${path}:"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "${result%:}"
|
||||
}
|
||||
|
||||
RBENV_VERSION="$(rbenv-version)"
|
||||
RBENV_COMMAND="$1"
|
||||
|
||||
if [ "$RBENV_VERSION" = "system" ]; then
|
||||
PATH="$(remove_from_path "${HOME}/.rbenv/shims")"
|
||||
RBENV_COMMAND_PATH="$(command -v "$RBENV_COMMAND")"
|
||||
else
|
||||
RBENV_COMMAND_PATH="${HOME}/.rbenv/versions/${RBENV_VERSION}/bin/${RBENV_COMMAND}"
|
||||
fi
|
||||
|
||||
shopt -s nullglob
|
||||
RBENV_WHICH_PLUGINS=(/etc/rbenv.d/which/*.bash ${HOME}/.rbenv/rbenv.d/which/*.bash)
|
||||
|
|
Loading…
Reference in a new issue