-
Notifications
You must be signed in to change notification settings - Fork 0
/
.20_python.bash
executable file
·46 lines (43 loc) · 1.15 KB
/
.20_python.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
__python_pyenv() {
PYENV_ROOT="${HOME}/.pyenv"
if [[ ! -d "${PYENV_ROOT}" ]]; then
return 0
fi
export PYENV_ROOT
unset -f pyenv &> /dev/null
# `pyenv init -` but with some portability tweaks
# shellcheck disable=SC1078
PATH="$(bash --norc -ec 'IFS=:; paths=($PATH);
for i in ${!paths[@]}; do
if [[ ${paths[i]} == "''${PYENV_ROOT}/shims''" ]]; then unset '\''paths[i]'\'';
fi; done;
echo "${paths[*]}"' )"
PATH="${PYENV_ROOT}/shims:${PATH}"
export PATH
PYENV_SHELL=$(basename "${SHELL}")
export PYENV_SHELL
source "$(dirname "$(readlink -f "$(which pyenv)")")/../completions/pyenv.zsh"
command pyenv rehash 2>/dev/null
pyenv() {
local command
command="${1:-}"
if [ "$#" -gt 0 ]; then
shift
fi
case "$command" in
rehash|shell)
eval "$(pyenv "sh-$command" "$@")"
;;
*)
command pyenv "$command" "$@"
;;
esac
}
}
__python_pyenv
__python_pip() {
if [[ ! -x "$(command -v pip)" && -x "$(command -v pip3)" ]]; then
alias pip=pip3
fi
}
__python_pip