mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-22 05:40:08 +00:00
Add plugin for pipenv (#6698)
- Add completion for pipenv - Auto activate and deactivate for pipenv shell - Add aliases for the most common pipenv commands
This commit is contained in:
parent
76c7bd57c3
commit
4cadbcd235
2 changed files with 70 additions and 0 deletions
28
plugins/pipenv/README.md
Normal file
28
plugins/pipenv/README.md
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Pipenv
|
||||
|
||||
## Installation
|
||||
In your `.zshrc` file, add `pipenv` to the plugins section
|
||||
|
||||
```
|
||||
plugins=(... pipenv ...)
|
||||
```
|
||||
|
||||
## Features
|
||||
This plugin provides some features to simplify the use of Pipenv while working on ZSH.
|
||||
- Adds completion for pipenv
|
||||
- Auto activates and deactivates pipenv shell
|
||||
- Adds short aliases for common pipenv commands
|
||||
- `pch` is aliased to `pipenv check`
|
||||
- `pcl` is aliased to `pipenv clean`
|
||||
- `pgr` is aliased to `pipenv graph`
|
||||
- `pi` is aliased to `pipenv install`
|
||||
- `pidev` is aliased to `pipenv install --dev`
|
||||
- `pl` is aliased to `pipenv lock`
|
||||
- `po` is aliased to `pipenv open`
|
||||
- `prun` is aliased to `pipenv run`
|
||||
- `psh` is aliased to `pipenv shell`
|
||||
- `psy` is aliased to `pipenv sync`
|
||||
- `pu` is aliased to `pipenv uninstall`
|
||||
- `pwh` is aliased to `pipenv --where`
|
||||
- `pvenv` is aliased to `pipenv --venv`
|
||||
- `ppy` is aliased to `pipenv --py`
|
42
plugins/pipenv/pipenv.plugin.zsh
Normal file
42
plugins/pipenv/pipenv.plugin.zsh
Normal file
|
@ -0,0 +1,42 @@
|
|||
# Pipenv completion
|
||||
_pipenv() {
|
||||
eval $(env COMMANDLINE="${words[1,$CURRENT]}" _PIPENV_COMPLETE=complete-zsh pipenv)
|
||||
}
|
||||
compdef _pipenv pipenv
|
||||
|
||||
# Automatic pipenv shell activation/deactivation
|
||||
_togglePipenvShell() {
|
||||
# deactivate shell if Pipfile doesn't exist and not in a subdir
|
||||
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
|
||||
}
|
||||
chpwd_functions+=(_togglePipenvShell)
|
||||
|
||||
# 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"
|
Loading…
Reference in a new issue