From a5bb1d1044a7e5da5b6fbea642bef718029afa86 Mon Sep 17 00:00:00 2001 From: Jacob Chapman <7908073+chapmanjacobd@users.noreply.github.com> Date: Mon, 18 Apr 2022 19:49:41 -0500 Subject: [PATCH 1/4] Maintain control flow, cd-ing in other functions --- conf.d/pipenv.fish | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/conf.d/pipenv.fish b/conf.d/pipenv.fish index a4bb906..34edf39 100644 --- a/conf.d/pipenv.fish +++ b/conf.d/pipenv.fish @@ -15,20 +15,24 @@ function __pipenv_shell_activate --on-variable PWD end if not test -n "$PIPENV_ACTIVE" - if pipenv --venv >/dev/null 2>&1 - set -x __pipenv_fish_initial_pwd "$PWD" + if test status current-command = "cd" or test status current-command = "__pipenv_shell_activate" + if pipenv --venv >/dev/null 2>&1 + set -x __pipenv_fish_initial_pwd "$PWD" - if [ "$pipenv_fish_fancy" = 'yes' ] - set -- __pipenv_fish_arguments $__pipenv_fish_arguments --fancy - end + if [ "$pipenv_fish_fancy" = 'yes' ] + set -- __pipenv_fish_arguments $__pipenv_fish_arguments --fancy + end - pipenv shell $__pipenv_fish_arguments + pipenv shell $__pipenv_fish_arguments - set -e __pipenv_fish_initial_pwd - if test -n "$__pipenv_fish_final_pwd" - cd "$__pipenv_fish_final_pwd" - set -e __pipenv_fish_final_pwd - end + set -e __pipenv_fish_initial_pwd + if test -n "$__pipenv_fish_final_pwd" + cd "$__pipenv_fish_final_pwd" + set -e __pipenv_fish_final_pwd + end + end + else + . $(pipenv --venv)/bin/activate.fish end end end From 1cee10bd17b62631756c95e4fdef036154d00769 Mon Sep 17 00:00:00 2001 From: Jacob Chapman <7908073+chapmanjacobd@users.noreply.github.com> Date: Mon, 18 Apr 2022 20:05:45 -0500 Subject: [PATCH 2/4] Update pipenv.fish make it not broken --- conf.d/pipenv.fish | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conf.d/pipenv.fish b/conf.d/pipenv.fish index 34edf39..42e1494 100644 --- a/conf.d/pipenv.fish +++ b/conf.d/pipenv.fish @@ -15,7 +15,8 @@ function __pipenv_shell_activate --on-variable PWD end if not test -n "$PIPENV_ACTIVE" - if test status current-command = "cd" or test status current-command = "__pipenv_shell_activate" + set curcmd (status current-command) + if [ "$curcmd" = 'cd' -a "$curcmd" = "__pipenv_shell_activate" ] if pipenv --venv >/dev/null 2>&1 set -x __pipenv_fish_initial_pwd "$PWD" From 174c3a762055338a6cb4a0bd7ea54a858dcc7733 Mon Sep 17 00:00:00 2001 From: Jacob Chapman <7908073+chapmanjacobd@users.noreply.github.com> Date: Mon, 18 Apr 2022 20:09:03 -0500 Subject: [PATCH 3/4] make it even less broken :) --- conf.d/pipenv.fish | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/conf.d/pipenv.fish b/conf.d/pipenv.fish index 42e1494..258d83c 100644 --- a/conf.d/pipenv.fish +++ b/conf.d/pipenv.fish @@ -15,25 +15,25 @@ function __pipenv_shell_activate --on-variable PWD end if not test -n "$PIPENV_ACTIVE" - set curcmd (status current-command) - if [ "$curcmd" = 'cd' -a "$curcmd" = "__pipenv_shell_activate" ] - if pipenv --venv >/dev/null 2>&1 + if pipenv --venv >/dev/null 2>&1 set -x __pipenv_fish_initial_pwd "$PWD" if [ "$pipenv_fish_fancy" = 'yes' ] set -- __pipenv_fish_arguments $__pipenv_fish_arguments --fancy end - pipenv shell $__pipenv_fish_arguments + set curcmd (status current-command) + if [ "$curcmd" = 'cd' -o "$curcmd" = "__pipenv_shell_activate" ] + pipenv shell $__pipenv_fish_arguments + else + . $(pipenv --venv)/bin/activate.fish + end set -e __pipenv_fish_initial_pwd if test -n "$__pipenv_fish_final_pwd" cd "$__pipenv_fish_final_pwd" set -e __pipenv_fish_final_pwd end - end - else - . $(pipenv --venv)/bin/activate.fish end end end From e32b4138c6ebf77c0fe765998227aca8cfb8d9ff Mon Sep 17 00:00:00 2001 From: Jacob Chapman <7908073+chapmanjacobd@users.noreply.github.com> Date: Mon, 18 Apr 2022 20:25:41 -0500 Subject: [PATCH 4/4] Update pipenv.fish --- conf.d/pipenv.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.d/pipenv.fish b/conf.d/pipenv.fish index 258d83c..223e951 100644 --- a/conf.d/pipenv.fish +++ b/conf.d/pipenv.fish @@ -9,7 +9,7 @@ function __pipenv_shell_activate --on-variable PWD if not test -e "$PWD/Pipfile" if not string match -q "$__pipenv_fish_initial_pwd"/'*' "$PWD/" set -U __pipenv_fish_final_pwd "$PWD" - exit + deactivate or exit end return end