mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-07 20:31:01 -05:00
Reliably detect parent shell in pyenv init
(fixes #93)
Imported changes from sstephenson/rbenv#453.
This commit is contained in:
parent
6efb3c327f
commit
5bff9c773a
3 changed files with 23 additions and 9 deletions
|
@ -22,7 +22,9 @@ done
|
|||
|
||||
shell="$1"
|
||||
if [ -z "$shell" ]; then
|
||||
shell="$(basename "$SHELL")"
|
||||
shell="$(ps c -p $(ps -p $$ -o 'ppid=' 2>/dev/null) -o 'comm=' 2>/dev/null || true)"
|
||||
shell="${shell##-}"
|
||||
shell="$(basename "${shell:-$SHELL}")"
|
||||
fi
|
||||
|
||||
READLINK=$(type -p greadlink readlink | head -1)
|
||||
|
@ -75,7 +77,7 @@ if [ -z "$print" ]; then
|
|||
echo
|
||||
case "$shell" in
|
||||
fish )
|
||||
echo '. (pyenv init -|psub)'
|
||||
echo 'status --is-interactive; and . (pyenv init -|psub)'
|
||||
;;
|
||||
* )
|
||||
echo 'eval "$(pyenv init -)"'
|
||||
|
@ -100,8 +102,22 @@ if [[ ":${PATH}:" != *:"${PYENV_ROOT}/shims":* ]]; then
|
|||
esac
|
||||
fi
|
||||
|
||||
case "$shell" in
|
||||
fish )
|
||||
echo "setenv PYENV_SHELL $shell"
|
||||
;;
|
||||
* )
|
||||
echo "export PYENV_SHELL=$shell"
|
||||
;;
|
||||
esac
|
||||
|
||||
completion="${root}/completions/pyenv.${shell}"
|
||||
[ -r "$completion" ] && echo ". '$completion'"
|
||||
if [ -r "$completion" ]; then
|
||||
case "$shell" in
|
||||
fish ) echo ". '$completion'" ;;
|
||||
* ) echo "source '$completion'" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ -z "$no_rehash" ]; then
|
||||
echo 'pyenv rehash 2>/dev/null'
|
||||
|
|
|
@ -7,7 +7,7 @@ if [ "$1" = "--complete" ]; then
|
|||
exec pyenv-rehash --complete
|
||||
fi
|
||||
|
||||
shell="$(basename "$SHELL")"
|
||||
shell="$(basename "${PYENV_SHELL:-$SHELL}")"
|
||||
|
||||
# When pyenv shell integration is enabled, delegate to pyenv-rehash,
|
||||
# then tell the shell to empty its command lookup cache.
|
||||
|
@ -15,11 +15,9 @@ pyenv-rehash
|
|||
|
||||
case "$shell" in
|
||||
fish )
|
||||
or='; or'
|
||||
# no rehash support
|
||||
;;
|
||||
* )
|
||||
or='||'
|
||||
echo "hash -r 2>/dev/null || true"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "hash -r 2>/dev/null $or true"
|
||||
|
|
|
@ -24,7 +24,7 @@ if [ "$1" = "--complete" ]; then
|
|||
fi
|
||||
|
||||
versions=("$@")
|
||||
shell="$(basename "$SHELL")"
|
||||
shell="$(basename "${PYENV_SHELL:-$SHELL}")"
|
||||
|
||||
if [ -z "$versions" ]; then
|
||||
if [ -z "$PYENV_VERSION" ]; then
|
||||
|
|
Loading…
Reference in a new issue