This commit is contained in:
Matheus Felipe 2026-05-18 15:29:38 -03:00 committed by GitHub
commit 7adacc7245
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 9 deletions

View file

@ -10,7 +10,7 @@ plugins=(... pipenv ...)
## Features ## Features
- Adds completion for pipenv - Adds completion for pipenv ([install the `argcomplete` package to get it working with pipenv >= 2026.5.0](https://pipenv.pypa.io/en/latest/shell.html#shell-completion))
- Auto activates and deactivates pipenv shell - Auto activates and deactivates pipenv shell
- Adds short aliases for common pipenv commands - Adds short aliases for common pipenv commands
- `pch` is aliased to `pipenv check` - `pch` is aliased to `pipenv check`

View file

@ -2,6 +2,27 @@ if (( ! $+commands[pipenv] )); then
return return
fi fi
# Compatibility note:
# pipenv < 2026.5.0 used Click-based shell completion driven by the
# _PIPENV_COMPLETE environment variable.
#
# pipenv >= 2026.5.0 removed this mechanism and switched to argcomplete-based
# completion using register-python-argcomplete instead.
autoload -Uz is-at-least
_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
eval "$(register-python-argcomplete pipenv)"
else
# 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.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_pipenv" ]]; then if [[ ! -f "$ZSH_CACHE_DIR/completions/_pipenv" ]]; then
@ -11,6 +32,7 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_pipenv" ]]; then
fi fi
_PIPENV_COMPLETE=zsh_source pipenv >| "$ZSH_CACHE_DIR/completions/_pipenv" &| _PIPENV_COMPLETE=zsh_source pipenv >| "$ZSH_CACHE_DIR/completions/_pipenv" &|
fi
if zstyle -T ':omz:plugins:pipenv' auto-shell; then if zstyle -T ':omz:plugins:pipenv' auto-shell; then
# Automatic pipenv shell activation/deactivation # Automatic pipenv shell activation/deactivation
@ -34,6 +56,7 @@ if zstyle -T ':omz:plugins:pipenv' auto-shell; then
fi fi
fi fi
} }
autoload -U add-zsh-hook autoload -U add-zsh-hook
add-zsh-hook chpwd _togglePipenvShell add-zsh-hook chpwd _togglePipenvShell
_togglePipenvShell _togglePipenvShell