From bd3a4db8e5065017f330f2a91d7db6f9836cf039 Mon Sep 17 00:00:00 2001 From: Mark Keisler Date: Mon, 25 Jul 2022 12:41:00 -0500 Subject: [PATCH] Allow use of cd to positions in dirstack for zsh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- templates/zsh.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/zsh.txt b/templates/zsh.txt index 11b69ed..331e5a3 100644 --- a/templates/zsh.txt +++ b/templates/zsh.txt @@ -67,7 +67,7 @@ function __zoxide_z() { \builtin printf 'zoxide: $OLDPWD is not set' return 1 fi - elif [[ "$#" -eq 1 ]] && [[ -d "$1" ]]; then + elif [[ "$#" -eq 1 ]] && [[ -d "$1" ]] || [[ "$1" =~ ^[-+][1-9]$ ]]; then __zoxide_cd "$1" elif [[ "$@[-1]" == "${__zoxide_z_prefix}"* ]]; then # shellcheck disable=SC2124