Browse Source

Add support for 'pip', 'pip2', 'pip3' completion

Since `pip completion --zsh` might be slow, we cache it beforehand.
The implementation is along the lines of 'npm' completion in 'node' module.
master
Indrajit Raychaudhuri 8 years ago committed by Indrajit Raychaudhuri
parent
commit
4f87376b50
  1. 14
      modules/python/init.zsh

14
modules/python/init.zsh

@ -46,6 +46,20 @@ if (( $? && $+commands[virtualenvwrapper.sh] )); then
source "$commands[virtualenvwrapper.sh]" source "$commands[virtualenvwrapper.sh]"
fi fi
# Load PIP completion.
if (( $+commands[pip] )); then
cache_file="${0:h}/cache.zsh"
if [[ "$commands[pip]" -nt "$cache_file" || ! -s "$cache_file" ]]; then
# pip is slow; cache its output. And also support 'pip2', 'pip3' variants
pip completion --zsh | sed -e "s|compctl -K [-_[:alnum:]]* pip|& pip2 pip3|" >! "$cache_file" 2> /dev/null
fi
source "$cache_file"
unset cache_file
fi
# #
# Aliases # Aliases
# #

Loading…
Cancel
Save