Skip to content

Commit

Permalink
python: Make cached completion file mangling more reliable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
indrajitr committed Dec 11, 2018
1 parent 2286662 commit 53286eb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/python/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,11 @@ if (( $#commands[(i)pip(|[23])] )); then
|| ! -s "$cache_file" ]]; then
# pip is slow; cache its output. And also support 'pip2', 'pip3' variants
$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

source "$cache_file"

unset cache_file pip_command
fi

Expand Down

0 comments on commit 53286eb

Please sign in to comment.