From bd5ebba834c53e730671d9d24d93eb98b812a579 Mon Sep 17 00:00:00 2001 From: Eddie Romanov <81505200+SnoopDraugg@users.noreply.github.com> Date: Sun, 16 Apr 2023 03:49:04 -0400 Subject: feat(pipenv): add pupd alias (#11616) --- plugins/pipenv/README.md | 1 + plugins/pipenv/pipenv.plugin.zsh | 1 + 2 files changed, 2 insertions(+) (limited to 'plugins/pipenv') diff --git a/plugins/pipenv/README.md b/plugins/pipenv/README.md index ab1c1e442..4329feb32 100644 --- a/plugins/pipenv/README.md +++ b/plugins/pipenv/README.md @@ -23,6 +23,7 @@ This plugin provides some features to simplify the use of Pipenv while working o - `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` diff --git a/plugins/pipenv/pipenv.plugin.zsh b/plugins/pipenv/pipenv.plugin.zsh index 244bd6b7c..22d1a3131 100644 --- a/plugins/pipenv/pipenv.plugin.zsh +++ b/plugins/pipenv/pipenv.plugin.zsh @@ -47,6 +47,7 @@ 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" -- cgit v1.2.3-70-g09d2 From 079dbff2c4f22935a71101c511e2285327d8ab68 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Wed, 6 Sep 2023 19:01:41 +0200 Subject: feat(pipenv): add option to disable auto shell feature Closes #11472 --- plugins/pipenv/README.md | 15 ++++++++++++++- plugins/pipenv/pipenv.plugin.zsh | 38 ++++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 19 deletions(-) (limited to 'plugins/pipenv') diff --git a/plugins/pipenv/README.md b/plugins/pipenv/README.md index 4329feb32..e78ef0e3b 100644 --- a/plugins/pipenv/README.md +++ b/plugins/pipenv/README.md @@ -1,6 +1,7 @@ # Pipenv ## Installation + In your `.zshrc` file, add `pipenv` to the plugins section ``` @@ -8,7 +9,9 @@ plugins=(... pipenv ...) ``` ## Features -This plugin provides some features to simplify the use of Pipenv while working on ZSH. + +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 @@ -27,3 +30,13 @@ This plugin provides some features to simplify the use of Pipenv while working o - `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/plugins/pipenv/pipenv.plugin.zsh b/plugins/pipenv/pipenv.plugin.zsh index 22d1a3131..f81c266a4 100644 --- a/plugins/pipenv/pipenv.plugin.zsh +++ b/plugins/pipenv/pipenv.plugin.zsh @@ -12,28 +12,30 @@ fi _PIPENV_COMPLETE=zsh_source pipenv >| "$ZSH_CACHE_DIR/completions/_pipenv" &| -# 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 - exit +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 + exit + fi fi fi - fi - # activate the shell if Pipfile exists - if [[ "$PIPENV_ACTIVE" != 1 ]]; then - if [[ -f "$PWD/Pipfile" ]]; then - export pipfile_dir="$PWD" - pipenv shell + # activate the shell if Pipfile exists + if [[ "$PIPENV_ACTIVE" != 1 ]]; then + if [[ -f "$PWD/Pipfile" ]]; then + export pipfile_dir="$PWD" + pipenv shell + fi fi - fi -} -autoload -U add-zsh-hook -add-zsh-hook chpwd _togglePipenvShell -_togglePipenvShell + } + autoload -U add-zsh-hook + add-zsh-hook chpwd _togglePipenvShell + _togglePipenvShell +fi # Aliases alias pch="pipenv check" -- cgit v1.2.3-70-g09d2