diff options
| author | navewindre <boneyaard@gmail.com> | 2025-07-13 06:42:05 +0200 |
|---|---|---|
| committer | navewindre <boneyaard@gmail.com> | 2025-07-13 06:42:05 +0200 |
| commit | 02f14a9cb152561a5e44062aac79f3b700403b40 (patch) | |
| tree | 2db8ebda3b7f6f8777783aeb5c60018e6e1359d8 /home/.oh-my-zsh/plugins/pipenv | |
| parent | cbbdeb2f6b40a102a829f0c47cff052937231f00 (diff) | |
omz
Diffstat (limited to 'home/.oh-my-zsh/plugins/pipenv')
| -rw-r--r-- | home/.oh-my-zsh/plugins/pipenv/README.md | 40 | ||||
| -rw-r--r-- | home/.oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh | 57 |
2 files changed, 97 insertions, 0 deletions
diff --git a/home/.oh-my-zsh/plugins/pipenv/README.md b/home/.oh-my-zsh/plugins/pipenv/README.md new file mode 100644 index 0000000..429b6f1 --- /dev/null +++ b/home/.oh-my-zsh/plugins/pipenv/README.md @@ -0,0 +1,40 @@ +# Pipenv + +This plugin provides some features to simplify the use of [Pipenv](https://pipenv.pypa.io/) while working on ZSH. + +In your `.zshrc` file, add `pipenv` to the plugins section + +``` +plugins=(... pipenv ...) +``` + +## Features + +- 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` + - `pupd` is aliased to `pipenv update` + - `pwh` is aliased to `pipenv --where` + - `pvenv` is aliased to `pipenv --venv` + - `ppy` is aliased to `pipenv --py` + +## Configuration + +### Shell activation + +If you want to disable the shell activation and deactivation feature, add the following style to your `.zshrc` before sourcing `oh-my-zsh.sh`: + +```zsh +zstyle ':omz:plugins:pipenv' auto-shell no +``` diff --git a/home/.oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh b/home/.oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh new file mode 100644 index 0000000..76d66b3 --- /dev/null +++ b/home/.oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh @@ -0,0 +1,57 @@ +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" &| + +if zstyle -T ':omz:plugins:pipenv' auto-shell; then + # Automatic pipenv shell activation/deactivation + _togglePipenvShell() { + # deactivate shell if Pipfile doesn't exist and not in a subdir + if [[ ! -f "$PWD/Pipfile" ]]; then + if [[ "$PIPENV_ACTIVE" == 1 ]]; then + if [[ "$PWD" != "$pipfile_dir"* ]]; then + unset PIPENV_ACTIVE pipfile_dir + deactivate + fi + fi + fi + + # activate the shell if Pipfile exists + if [[ "$PIPENV_ACTIVE" != 1 ]]; then + if [[ -f "$PWD/Pipfile" ]]; then + export pipfile_dir="$PWD" + source "$(pipenv --venv)/bin/activate" + export PIPENV_ACTIVE=1 + fi + fi + } + autoload -U add-zsh-hook + add-zsh-hook chpwd _togglePipenvShell + _togglePipenvShell +fi + +# 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 pupd="pipenv update" +alias pwh="pipenv --where" +alias pvenv="pipenv --venv" +alias ppy="pipenv --py" |
