Skip to content

Commit

Permalink
Fix interaction between chpwd/_smartcd for reenter
Browse files Browse the repository at this point in the history
Fixes cxreg#28
  • Loading branch information
blueyed committed Sep 5, 2014
1 parent c8356e9 commit 762dbb6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/core/smartcd
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ function _smartcd() {
local _old_ifs="$IFS"
IFS=$' \t\n'
if [[ -z $smartcd_skip_action ]]; then
_smartcd_skip_chpwd=1
if [[ -n $1 ]] || [[ -z ${1-_} ]]; then
if [[ -n $ZSH_VERSION ]]; then
${=action} "$@"
Expand All @@ -444,6 +445,7 @@ function _smartcd() {
else
eval $action
fi
unset _smartcd_skip_chpwd
fi
local rv=$?
IFS="$_old_ifs"
Expand Down Expand Up @@ -757,13 +759,13 @@ function _smartcd() {
}

function _smartcd_hook() {
local cwd="$(pwd)"

# Skip this if we already ran smartcd for this directory
if [[ "x$cwd" != "$_smartcd_last_run_for" ]]; then
local smartcd_skip_action=1
_smartcd true "$cwd"
# Skip this if we are being invoked from _smartcd.
if [[ -n "$_smartcd_skip_chpwd" ]]; then
return
fi

local smartcd_skip_action=1
_smartcd true $PWD
}

function _smartcd_prompt_hook() {
Expand Down

0 comments on commit 762dbb6

Please sign in to comment.