From 580bf9bb241d7b6156ade9b44da7d04492b163a4 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Thu, 23 May 2013 11:24:08 -0400 Subject: [PATCH 1/3] Replacing cd override with zsh hook in virtualenvwrapper. --- plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index 35de50874..487bf2f36 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -40,10 +40,8 @@ if [[ -f "$wrapsource" ]]; then fi } - # New cd function that does the virtualenv magic - function cd { - builtin cd "$@" && workon_cwd - } + # Add zsh hook for virtualenv magic + add-zsh-hook chpwd workon_cwd fi else print "zsh virtualenvwrapper plugin: Cannot find virtualenvwrapper_lazy.sh. Please install with \`pip install virtualenvwrapper\`." From e34c6f9fe156dce2c8d3ae72542f7ef27312bd07 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Thu, 23 May 2013 11:51:08 -0400 Subject: [PATCH 2/3] Moving all autoenv logic to the plugin file. -Some of this was previously located in the directories lib. -Also unsetting the cd override function created by autoenv and replacing it with a zsh hook. --- lib/directories.zsh | 3 --- plugins/autoenv/autoenv.plugin.zsh | 8 ++++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/directories.zsh b/lib/directories.zsh index 1896945f4..b3a478d47 100644 --- a/lib/directories.zsh +++ b/lib/directories.zsh @@ -30,9 +30,6 @@ cd () { cd ../../../.. elif [[ "x$*" == "x......" ]]; then cd ../../../../.. - elif [ -d ~/.autoenv ]; then - source ~/.autoenv/activate.sh - autoenv_cd "$@" else builtin cd "$@" fi diff --git a/plugins/autoenv/autoenv.plugin.zsh b/plugins/autoenv/autoenv.plugin.zsh index ca5666979..960ff667c 100644 --- a/plugins/autoenv/autoenv.plugin.zsh +++ b/plugins/autoenv/autoenv.plugin.zsh @@ -1,3 +1,11 @@ +# Add the functions from autoenv if it's installed. +if [ -r ~/.autoenv/activate.sh ]; then + source ~/.autoenv/activate.sh + # Use a zsh hook instead of overriding the builtin cd. + unset -f cd + add-zsh-hook chpwd autoenv_init +fi + # The use_env call below is a reusable command to activate/create a new Python # virtualenv, requiring only a single declarative line of code in your .env files. # It only performs an action if the requested virtualenv is not the current one. From 63efab72ff42acc7d0a98278a6be4b72f217060d Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Thu, 23 May 2013 11:54:37 -0400 Subject: [PATCH 3/3] Removing cd override from directories lib. --- lib/directories.zsh | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/lib/directories.zsh b/lib/directories.zsh index b3a478d47..19694074d 100644 --- a/lib/directories.zsh +++ b/lib/directories.zsh @@ -21,20 +21,6 @@ alias 7='cd -7' alias 8='cd -8' alias 9='cd -9' -cd () { - if [[ "x$*" == "x..." ]]; then - cd ../.. - elif [[ "x$*" == "x...." ]]; then - cd ../../.. - elif [[ "x$*" == "x....." ]]; then - cd ../../../.. - elif [[ "x$*" == "x......" ]]; then - cd ../../../../.. - else - builtin cd "$@" - fi -} - alias md='mkdir -p' alias rd=rmdir alias d='dirs -v | head -10'