2023-01-03 09:44:53 +01:00
|
|
|
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" &|
|
2019-05-08 09:48:28 +02:00
|
|
|
|
|
|
|
# Automatic pipenv shell activation/deactivation
|
|
|
|
_togglePipenvShell() {
|
|
|
|
# deactivate shell if Pipfile doesn't exist and not in a subdir
|
2020-05-21 17:56:13 +02:00
|
|
|
if [[ ! -f "$PWD/Pipfile" ]]; then
|
2019-05-08 09:48:28 +02:00
|
|
|
if [[ "$PIPENV_ACTIVE" == 1 ]]; then
|
|
|
|
if [[ "$PWD" != "$pipfile_dir"* ]]; then
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# activate the shell if Pipfile exists
|
|
|
|
if [[ "$PIPENV_ACTIVE" != 1 ]]; then
|
2020-05-21 17:56:13 +02:00
|
|
|
if [[ -f "$PWD/Pipfile" ]]; then
|
2019-05-08 09:48:28 +02:00
|
|
|
export pipfile_dir="$PWD"
|
|
|
|
pipenv shell
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
2019-11-19 18:47:12 +01:00
|
|
|
autoload -U add-zsh-hook
|
|
|
|
add-zsh-hook chpwd _togglePipenvShell
|
2020-08-01 15:26:02 +02:00
|
|
|
_togglePipenvShell
|
2019-05-08 09:48:28 +02:00
|
|
|
|
|
|
|
# Aliases
|
|
|
|
alias pch="pipenv check"
|
|
|
|
alias pcl="pipenv clean"
|
|
|
|
alias pgr="pipenv graph"
|
|
|
|
alias pi="pipenv install"
|
|
|
|
alias pidev="pipenv install --dev"
|
|
|
|
alias pl="pipenv lock"
|
|
|
|
alias po="pipenv open"
|
|
|
|
alias prun="pipenv run"
|
|
|
|
alias psh="pipenv shell"
|
|
|
|
alias psy="pipenv sync"
|
|
|
|
alias pu="pipenv uninstall"
|
2023-04-16 09:49:04 +02:00
|
|
|
alias pupd="pipenv update"
|
2019-05-08 09:48:28 +02:00
|
|
|
alias pwh="pipenv --where"
|
|
|
|
alias pvenv="pipenv --venv"
|
|
|
|
alias ppy="pipenv --py"
|