]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh
4be61a92055931235324d149796dbb8f440ebf2a
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / pipenv / pipenv.plugin.zsh
1 # Pipenv completion
2 _pipenv() {
3   eval $(env COMMANDLINE="${words[1,$CURRENT]}" _PIPENV_COMPLETE=complete-zsh pipenv)
4 }
5 compdef _pipenv pipenv
6
7 # Automatic pipenv shell activation/deactivation
8 _togglePipenvShell() {
9   # deactivate shell if Pipfile doesn't exist and not in a subdir
10   if [[ ! -f "$PWD/Pipfile" ]]; then
11     if [[ "$PIPENV_ACTIVE" == 1 ]]; then
12       if [[ "$PWD" != "$pipfile_dir"* ]]; then
13         exit
14       fi
15     fi
16   fi
17
18   # activate the shell if Pipfile exists
19   if [[ "$PIPENV_ACTIVE" != 1 ]]; then
20     if [[ -f "$PWD/Pipfile" ]]; then
21       export pipfile_dir="$PWD"
22       pipenv shell
23     fi
24   fi
25 }
26 autoload -U add-zsh-hook
27 add-zsh-hook chpwd _togglePipenvShell
28 _togglePipenvShell
29
30 # Aliases
31 alias pch="pipenv check"
32 alias pcl="pipenv clean"
33 alias pgr="pipenv graph"
34 alias pi="pipenv install"
35 alias pidev="pipenv install --dev"
36 alias pl="pipenv lock"
37 alias po="pipenv open"
38 alias prun="pipenv run"
39 alias psh="pipenv shell"
40 alias psy="pipenv sync"
41 alias pu="pipenv uninstall"
42 alias pwh="pipenv --where"
43 alias pvenv="pipenv --venv"
44 alias ppy="pipenv --py"