diff --git a/conf.d/pipenv.fish b/conf.d/pipenv.fish index a4bb906..223e951 100644 --- a/conf.d/pipenv.fish +++ b/conf.d/pipenv.fish @@ -9,26 +9,31 @@ 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 if not test -n "$PIPENV_ACTIVE" if pipenv --venv >/dev/null 2>&1 - set -x __pipenv_fish_initial_pwd "$PWD" + 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 + 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 + 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 end end