diff --git a/templates/bash.txt b/templates/bash.txt index 5aa15ea..50ed2d3 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -75,7 +75,7 @@ function __zoxide_z() { echo 'zoxide: $OLDPWD is not set' return 1 fi - elif [ "$#" -eq 1 ] && [ -d "$1" ]; then + elif [ "$#" -eq 1 ] && (cd "$1" &>{{ Opts::DEVNULL }}); then __zoxide_cd "$1" else local __zoxide_result diff --git a/templates/posix.txt b/templates/posix.txt index 815f770..58921e1 100644 --- a/templates/posix.txt +++ b/templates/posix.txt @@ -79,7 +79,7 @@ __zoxide_z() { echo 'zoxide: $OLDPWD is not set' return 1 fi - elif [ "$#" -eq 1 ] && [ -d "$1" ]; then + elif [ "$#" -eq 1 ] && (cd "$1" >{{ Opts::DEVNULL }}) 2>&1; then __zoxide_cd "$1" else __zoxide_result="$(zoxide query -- "$@")" && __zoxide_cd "${__zoxide_result}" diff --git a/templates/zsh.txt b/templates/zsh.txt index acb900b..fdfaf73 100644 --- a/templates/zsh.txt +++ b/templates/zsh.txt @@ -59,7 +59,9 @@ function __zoxide_z() { echo "zoxide: \\$OLDPWD is not set" return 1 fi - elif ! { [ "$#" -eq 1 ] && __zoxide_cd "$1" &>{{ Opts::DEVNULL }}; }; then + elif [ "$#" -eq 1 ] && (cd "$1" &>{{ Opts::DEVNULL }}) then + __zoxide_cd "$1" + else local __zoxide_result __zoxide_result="$(zoxide query -- "$@")" && __zoxide_cd "$__zoxide_result" fi