summaryrefslogtreecommitdiff
path: root/plugins/pipenv/pipenv.plugin.zsh
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2023-01-17 12:46:15 +0100
committerTuowen Zhao <ztuowen@gmail.com>2023-01-17 12:46:15 +0100
commitdb7efd2336e4dbe6abf321b00dbc11bc5afb1355 (patch)
tree720a58ff82bf0a0e0167594131f872d453b1828e /plugins/pipenv/pipenv.plugin.zsh
parent04b8c052e5b624873b352889423c753ed1baf9c4 (diff)
parent8f0e296dbf27026ea0515ebae0d3cc41f236ecdc (diff)
downloadzsh-db7efd2336e4dbe6abf321b00dbc11bc5afb1355.tar.gz
zsh-db7efd2336e4dbe6abf321b00dbc11bc5afb1355.tar.bz2
zsh-db7efd2336e4dbe6abf321b00dbc11bc5afb1355.zip
Merge remote-tracking branch 'github/master'
Diffstat (limited to 'plugins/pipenv/pipenv.plugin.zsh')
-rw-r--r--plugins/pipenv/pipenv.plugin.zsh18
1 files changed, 13 insertions, 5 deletions
diff --git a/plugins/pipenv/pipenv.plugin.zsh b/plugins/pipenv/pipenv.plugin.zsh
index 4be61a920..244bd6b7c 100644
--- a/plugins/pipenv/pipenv.plugin.zsh
+++ b/plugins/pipenv/pipenv.plugin.zsh
@@ -1,8 +1,16 @@
-# Pipenv completion
-_pipenv() {
- eval $(env COMMANDLINE="${words[1,$CURRENT]}" _PIPENV_COMPLETE=complete-zsh pipenv)
-}
-compdef _pipenv pipenv
+if (( ! $+commands[pipenv] )); then
+ return
+fi
+
+# If the completion file doesn't exist yet, we need to autoload it and
+# bind it to `pipenv`. Otherwise, compinit will have already done that.
+if [[ ! -f "$ZSH_CACHE_DIR/completions/_pipenv" ]]; then
+ typeset -g -A _comps
+ autoload -Uz _pipenv
+ _comps[pipenv]=_pipenv
+fi
+
+_PIPENV_COMPLETE=zsh_source pipenv >| "$ZSH_CACHE_DIR/completions/_pipenv" &|
# Automatic pipenv shell activation/deactivation
_togglePipenvShell() {