zsh: allow z to navigate dirstack via +n and -n

This commit is contained in:
Mark Keisler 2022-07-26 02:56:42 -05:00 committed by Ajeet D'Souza
parent 209d86ab2f
commit 1306fba4ac
2 changed files with 3 additions and 10 deletions

View File

@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Fish: change fuzzy completion prefix to `z!`.
- Zsh: allow `z` to navigate dirstack via `+n` and `-n`.
## [0.8.2] - 2022-06-26

View File

@ -19,7 +19,7 @@ function __zoxide_pwd() {
# cd + custom logic based on the value of _ZO_ECHO.
function __zoxide_cd() {
# shellcheck disable=SC2164
\builtin cd -- "$@" {%- if echo %} && __zoxide_pwd {%- endif %}
\builtin cd -- "$@" >/dev/null {%- if echo %} && __zoxide_pwd {%- endif %}
}
{{ section }}
@ -59,15 +59,7 @@ function __zoxide_z() {
# shellcheck disable=SC2199
if [[ "$#" -eq 0 ]]; then
__zoxide_cd ~
elif [[ "$#" -eq 1 ]] && [[ "$1" = '-' ]]; then
if [[ -n "${OLDPWD}" ]]; then
__zoxide_cd "${OLDPWD}"
else
# shellcheck disable=SC2016
\builtin printf 'zoxide: $OLDPWD is not set'
return 1
fi
elif [[ "$#" -eq 1 ]] && [[ -d "$1" ]]; then
elif [[ "$#" -eq 1 ]] && { [[ -d "$1" ]] || [[ "$1" = '-' ]] || [[ "$1" =~ ^[-+][0-9]$ ]]; }; then
__zoxide_cd "$1"
elif [[ "$@[-1]" == "${__zoxide_z_prefix}"* ]]; then
# shellcheck disable=SC2124