Skip to content

Commit

Permalink
Fix bug in pip command detection
Browse files Browse the repository at this point in the history
  • Loading branch information
jcassee committed Jun 3, 2020
1 parent 7c89438 commit 1a1ae5c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions modules/python/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -147,21 +147,23 @@ if (( $+VIRTUALENVWRAPPER_VIRTUALENV || $+commands[virtualenv] )) && \
fi

# Load PIP completion.
for pip_command in pip{,2,3}; do
if [[ "$PYENV_ROOT" ]]; then
[[ "$(pyenv which "$pip_command" 2>/dev/null)" ]] && break
else
[[ "$(which "$pip_command" 2>/dev/null)" ]] && break
fi
done
if [[ "$pip_command" ]]; then
if [[ -n "$PYENV_ROOT" ]]; then
for pip in pip{,2,3}; do
pip_command="$(pyenv which "$pip" 2>/dev/null)"
[[ -n "$pip_command" ]] && break
done
unset pip
else
pip_command="$commands[(i)pip(|[23])]"
fi
if [[ -n "$pip_command" ]]; then
cache_file="${TMPDIR:-/tmp}/prezto-pip-cache.$UID.zsh"

if [[ "$pip_command" -nt "$cache_file" \
|| "${ZDOTDIR:-$HOME}/.zpreztorc" -nt "$cache_file" \
|| ! -s "$cache_file" ]]; then
# pip is slow; cache its output. And also support 'pip2', 'pip3' variants
$pip_command completion --zsh \
"$pip_command" completion --zsh \
| sed -e "s/\(compctl -K [-_[:alnum:]]* pip\).*/\1{,2,3}{,.{0..9}}/" \
>! "$cache_file" \
2> /dev/null
Expand Down

0 comments on commit 1a1ae5c

Please sign in to comment.