mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-29 04:53:17 +02:00
Plugin for pipenv
Add completion for pipenv Auto activate and deactivate for pipenv shell
This commit is contained in:
parent
0cec462621
commit
d75c3354d5
1 changed files with 36 additions and 0 deletions
36
plugins/pipenv/pipenv.plugin.zsh
Normal file
36
plugins/pipenv/pipenv.plugin.zsh
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#compdef pipenv
|
||||
_pipenv() {
|
||||
eval $(env COMMANDLINE="${words[1,$CURRENT]}" _PIPENV_COMPLETE=complete-zsh pipenv)
|
||||
}
|
||||
|
||||
_togglePipenvShell() {
|
||||
# deactivate shell if Pipfile doesn't exit and not in a sub dir
|
||||
if [[ ! -a "$PWD/Pipfile" ]]; then
|
||||
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
|
||||
if [[ -a "$PWD/Pipfile" ]]; then
|
||||
export pipfile_dir="$PWD"
|
||||
pipenv shell
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ "$(basename ${(%):-%x})" != "_pipenv" ]]; then
|
||||
autoload -U compinit && compinit
|
||||
compdef _pipenv pipenv
|
||||
fi
|
||||
|
||||
export PROMPT_COMMAND=_togglePipenvShell
|
||||
if [ -n "$ZSH_VERSION" ]; then
|
||||
function chpwd() {
|
||||
_togglePipenvShell
|
||||
}
|
||||
fi
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue