Browse Source

python: Make cached completion file mangling more reliable

While mangling cached completion file, we cannot just assume that
`$pip_command` would resolve to `pip` -- it might be `pip2` or `pip3`
depending on the relative position in zsh `$commands` array. Thus
replace the whole of 'pip*' with 'pip pip2 pip3' for compctl assignment.
master
Indrajit Raychaudhuri 6 years ago
parent
commit
38e5653e3c
  1. 3
      modules/python/init.zsh

3
modules/python/init.zsh

@ -160,10 +160,11 @@ if (( $#commands[(i)pip(|[23])] )); then
|| ! -s "$cache_file" ]]; then || ! -s "$cache_file" ]]; then
# pip is slow; cache its output. And also support 'pip2', 'pip3' variants # 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|& pip2 pip3|" >! "$cache_file" 2> /dev/null | sed -e "s|\(compctl -K [-_[:alnum:]]*\) pip|\1 pip pip2 pip3|" >! "$cache_file" 2> /dev/null
fi fi
source "$cache_file" source "$cache_file"
unset cache_file pip_command unset cache_file pip_command
fi fi

Loading…
Cancel
Save