2019-05-08 15:48:28 +08:00
|
|
|
# Pipenv completion
|
|
|
|
_pipenv() {
|
2020-08-01 21:26:02 +08:00
|
|
|
eval $(env COMMANDLINE="${words[1,$CURRENT]}" _PIPENV_COMPLETE=complete-zsh pipenv)
|
2019-05-08 15:48:28 +08:00
|
|
|
}
|
|
|
|
compdef _pipenv pipenv
|
|
|
|
|
|
|
|
# Automatic pipenv shell activation/deactivation
|
|
|
|
_togglePipenvShell() {
|
|
|
|
# deactivate shell if Pipfile doesn't exist and not in a subdir
|
2020-05-21 23:56:13 +08:00
|
|
|
if [[ ! -f "$PWD/Pipfile" ]]; then
|
2019-05-08 15:48:28 +08: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 23:56:13 +08:00
|
|
|
if [[ -f "$PWD/Pipfile" ]]; then
|
2019-05-08 15:48:28 +08:00
|
|
|
export pipfile_dir="$PWD"
|
|
|
|
pipenv shell
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
2019-11-20 01:47:12 +08:00
|
|
|
autoload -U add-zsh-hook
|
|
|
|
add-zsh-hook chpwd _togglePipenvShell
|
2020-08-01 21:26:02 +08:00
|
|
|
_togglePipenvShell
|
2019-05-08 15:48:28 +08: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"
|
|
|
|
alias pwh="pipenv --where"
|
|
|
|
alias pvenv="pipenv --venv"
|
|
|
|
alias ppy="pipenv --py"
|