|
|
|
@ -15,6 +15,7 @@ if [ "$1" = "--complete" ]; then |
|
|
|
echo bash |
|
|
|
echo fish |
|
|
|
echo ksh |
|
|
|
echo pwsh |
|
|
|
echo zsh |
|
|
|
exit |
|
|
|
fi |
|
|
|
@ -102,6 +103,10 @@ function detect_profile() { |
|
|
|
profile_explain="~/.bash_profile if it exists, otherwise ~/.profile" |
|
|
|
rc='~/.bashrc' |
|
|
|
;; |
|
|
|
pwsh ) |
|
|
|
profile='~/.config/powershell/profile.ps1' |
|
|
|
rc='~/.config/powershell/profile.ps1' |
|
|
|
;; |
|
|
|
zsh ) |
|
|
|
profile='~/.zprofile' |
|
|
|
rc='~/.zshrc' |
|
|
|
@ -150,6 +155,15 @@ function help_() { |
|
|
|
echo 'pyenv init - fish | source' |
|
|
|
echo |
|
|
|
;; |
|
|
|
pwsh ) |
|
|
|
echo '# Load pyenv automatically by appending' |
|
|
|
echo "# the following to $profile :" |
|
|
|
echo |
|
|
|
echo '$Env:PYENV_ROOT="$Env:HOME/.pyenv"' |
|
|
|
echo 'if (Test-Path -LP "$Env:PYENV_ROOT/bin" -PathType Container) {' |
|
|
|
echo ' $Env:PATH="$Env:PYENV_ROOT/bin:$Env:PATH" }' |
|
|
|
echo 'iex ((pyenv init -) -join "`n")' |
|
|
|
;; |
|
|
|
* ) |
|
|
|
echo '# Load pyenv automatically by appending' |
|
|
|
echo -n "# the following to " |
|
|
|
@ -186,6 +200,11 @@ function print_path() { |
|
|
|
print_path_prepend_shims |
|
|
|
echo 'end' |
|
|
|
;; |
|
|
|
pwsh ) |
|
|
|
echo 'if ( $Env:PATH -notmatch "'"${PYENV_ROOT}/shims"'" ) {' |
|
|
|
print_path_prepend_shims |
|
|
|
echo '}' |
|
|
|
;; |
|
|
|
* ) |
|
|
|
echo 'if [[ ":$PATH:" != *'\':"${PYENV_ROOT}"/shims:\''* ]]; then' |
|
|
|
print_path_prepend_shims |
|
|
|
@ -199,6 +218,10 @@ function print_path() { |
|
|
|
echo 'set -eg PATH[$pyenv_index]; end; set -e pyenv_index' |
|
|
|
print_path_prepend_shims |
|
|
|
;; |
|
|
|
pwsh ) |
|
|
|
echo '$Env:PATH="$(($Env:PATH -split '"':'"' | where { -not ($_ -match '"'${PYENV_ROOT}/shims'"') }) -join '"':'"')"' |
|
|
|
print_path_prepend_shims |
|
|
|
;; |
|
|
|
* ) |
|
|
|
# Some distros (notably Debian-based) set Bash's SSH_SOURCE_BASHRC compilation option |
|
|
|
# that makes it source `bashrc` under SSH even when not interactive. |
|
|
|
@ -223,6 +246,9 @@ function print_path_prepend_shims() { |
|
|
|
fish ) |
|
|
|
echo 'set -gx PATH '\'"${PYENV_ROOT}/shims"\'' $PATH' |
|
|
|
;; |
|
|
|
pwsh ) |
|
|
|
echo '$Env:PATH="'"${PYENV_ROOT}"'/shims:$Env:PATH"' |
|
|
|
;; |
|
|
|
* ) |
|
|
|
echo 'export PATH="'"${PYENV_ROOT}"'/shims:${PATH}"' |
|
|
|
;; |
|
|
|
@ -234,6 +260,9 @@ function print_env() { |
|
|
|
fish ) |
|
|
|
echo "set -gx PYENV_SHELL $shell" |
|
|
|
;; |
|
|
|
pwsh ) |
|
|
|
echo '$Env:PYENV_SHELL="'"$shell"'"' |
|
|
|
;; |
|
|
|
* ) |
|
|
|
echo "export PYENV_SHELL=$shell" |
|
|
|
;; |
|
|
|
@ -243,13 +272,27 @@ function print_env() { |
|
|
|
function print_completion() { |
|
|
|
completion="${0%/*/*}/completions/pyenv.${shell}" |
|
|
|
if [ -r "$completion" ]; then |
|
|
|
echo "source '$completion'" |
|
|
|
case "$shell" in |
|
|
|
pwsh ) |
|
|
|
echo "iex (gc $completion -Raw)" |
|
|
|
;; |
|
|
|
* ) |
|
|
|
echo "source '$completion'" |
|
|
|
;; |
|
|
|
esac |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
function print_rehash() { |
|
|
|
if [ -z "$no_rehash" ]; then |
|
|
|
echo 'command pyenv rehash 2>/dev/null' |
|
|
|
case "$shell" in |
|
|
|
pwsh ) |
|
|
|
echo '& pyenv rehash 2>/dev/null' |
|
|
|
;; |
|
|
|
* ) |
|
|
|
echo 'command pyenv rehash 2>/dev/null' |
|
|
|
;; |
|
|
|
esac |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
@ -270,6 +313,25 @@ function print_shell_function() { |
|
|
|
end |
|
|
|
end' |
|
|
|
;; |
|
|
|
pwsh ) |
|
|
|
cat <<EOS |
|
|
|
function pyenv { |
|
|
|
\$command="" |
|
|
|
if ( \$args.Count -gt 0 ) { |
|
|
|
\$command, \$args = \$args |
|
|
|
} |
|
|
|
|
|
|
|
if ( ("${commands[*]}" -split ' ') -contains \$command ) { |
|
|
|
\$shell_cmds = (& (get-command -commandtype application pyenv) sh-\$command \$args) |
|
|
|
if ( \$shell_cmds.Count -gt 0 ) { |
|
|
|
iex (\$shell_cmds -join "\`n") |
|
|
|
} |
|
|
|
} else { |
|
|
|
& (get-command -commandtype application pyenv) \$command \$args |
|
|
|
} |
|
|
|
} |
|
|
|
EOS |
|
|
|
;; |
|
|
|
ksh | ksh93 | mksh ) |
|
|
|
echo \ |
|
|
|
'function pyenv { |
|
|
|
@ -281,8 +343,8 @@ end' |
|
|
|
local command=${1:-}' |
|
|
|
;; |
|
|
|
esac |
|
|
|
|
|
|
|
if [ "$shell" != "fish" ]; then |
|
|
|
|
|
|
|
if [ "$shell" != "fish" ] && [ "$shell" != "pwsh" ]; then |
|
|
|
IFS="|" |
|
|
|
echo \ |
|
|
|
' [ "$#" -gt 0 ] && shift |
|
|
|
|