Allow use of cd to positions in dirstack for zsh

man zshbuiltins excerpt:
The  third  form  of  cd extracts an entry from the directory stack, and
changes to that directory.  An argument of the form  `+n'  identifies  a
stack entry by counting from the left of the list shown by the dirs com‐
mand, starting with zero.  An argument of the form `-n' counts from  the
right.  If the PUSHD_MINUS option is set, the meanings of `+' and `-' in
this context are swapped.  If the POSIX_CD option is set, this  form  of
cd is not recognised and will be interpreted as the first form.
This commit is contained in:
Mark Keisler 2022-07-25 12:41:00 -05:00
parent 209d86ab2f
commit bd3a4db8e5
1 changed files with 1 additions and 1 deletions

View File

@ -67,7 +67,7 @@ function __zoxide_z() {
\builtin printf 'zoxide: $OLDPWD is not set' \builtin printf 'zoxide: $OLDPWD is not set'
return 1 return 1
fi fi
elif [[ "$#" -eq 1 ]] && [[ -d "$1" ]]; then elif [[ "$#" -eq 1 ]] && [[ -d "$1" ]] || [[ "$1" =~ ^[-+][1-9]$ ]]; then
__zoxide_cd "$1" __zoxide_cd "$1"
elif [[ "$@[-1]" == "${__zoxide_z_prefix}"* ]]; then elif [[ "$@[-1]" == "${__zoxide_z_prefix}"* ]]; then
# shellcheck disable=SC2124 # shellcheck disable=SC2124