00c37b6991895aac0398a24d7d8b78cda63dec05
- Author
- Alastair Rankine <alastair@girtby.net>
- Committer
- GitHub <noreply@github.com>
- Date
Message
feat(pipenv): standarize completion generation (#11424)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
Closes #11423
Diff
1diff --git a/plugins/pipenv/pipenv.plugin.zsh b/plugins/pipenv/pipenv.plugin.zsh
2index 4be61a92055931235324d149796dbb8f440ebf2a..244bd6b7c2ba2902fbcbd0bc7801f6dfb68d7365 100644
3--- a/plugins/pipenv/pipenv.plugin.zsh
4+++ b/plugins/pipenv/pipenv.plugin.zsh
5@@ -1,8 +1,16 @@
6-# Pipenv completion
7-_pipenv() {
8- eval $(env COMMANDLINE="${words[1,$CURRENT]}" _PIPENV_COMPLETE=complete-zsh pipenv)
9-}
10-compdef _pipenv pipenv
11+if (( ! $+commands[pipenv] )); then
12+ return
13+fi
14+
15+# If the completion file doesn't exist yet, we need to autoload it and
16+# bind it to `pipenv`. Otherwise, compinit will have already done that.
17+if [[ ! -f "$ZSH_CACHE_DIR/completions/_pipenv" ]]; then
18+ typeset -g -A _comps
19+ autoload -Uz _pipenv
20+ _comps[pipenv]=_pipenv
21+fi
22+
23+_PIPENV_COMPLETE=zsh_source pipenv >| "$ZSH_CACHE_DIR/completions/_pipenv" &|
24
25 # Automatic pipenv shell activation/deactivation
26 _togglePipenvShell() {