fix(pipenv): add argcomplete compatibility for >= 2026.5.0 and keep legacy completion

This commit is contained in:
Matheus Felipe 2026-05-18 15:29:14 -03:00
commit 9a150a71c2
No known key found for this signature in database
GPG key ID: E6056C95900163D1

View file

@ -9,15 +9,19 @@ fi
# pipenv >= 2026.5.0 removed this mechanism and switched to argcomplete-based # pipenv >= 2026.5.0 removed this mechanism and switched to argcomplete-based
# completion using register-python-argcomplete instead. # completion using register-python-argcomplete instead.
if (( $+commands[register-python-argcomplete] )); then autoload -Uz is-at-least
# pipenv >= 2026.5.0 (argcomplete-based completion)
autoload -U bashcompinit _pipenv_version="${$(pipenv --version 2>/dev/null)#pipenv, version }"
if is-at-least 2026.5.0 "$_pipenv_version" && (( $+commands[register-python-argcomplete] )); then
# argcomplete-based completion
autoload -Uz bashcompinit
bashcompinit bashcompinit
eval "$(register-python-argcomplete pipenv)" eval "$(register-python-argcomplete pipenv)"
else else
# pipenv < 2026.5.0 (legacy Click-based completion via _PIPENV_COMPLETE) # legacy Click-based completion via _PIPENV_COMPLETE
# If the completion file doesn't exist yet, we need to autoload it and # 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. # bind it to `pipenv`. Otherwise, compinit will have already done that.