diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fb7e07..9d7d60b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fish: not providing `cd` completions when there is a space in the path. -- Fish: providing `z` completions when the preceding argument starts with `z!`. +- Bash/Fish: providing `z` completions when the last argument starts with `z!`. +- Bash/Fish: attempting to `cd` when the last argument is `z!`. ## [0.9.0] - 2023-01-08 diff --git a/templates/bash.txt b/templates/bash.txt index cb44cef..1af9b1f 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -75,7 +75,7 @@ function __zoxide_z() { __zoxide_cd "${OLDPWD}" elif [[ $# -eq 1 && -d $1 ]]; then __zoxide_cd "$1" - elif [[ ${@: -1} == "${__zoxide_z_prefix}"* ]]; then + elif [[ ${@: -1} == "${__zoxide_z_prefix}"?* ]]; then # shellcheck disable=SC2124 \builtin local result="${@: -1}" __zoxide_cd "{{ "${result:${#__zoxide_z_prefix}}" }}" @@ -130,7 +130,7 @@ if [[ ${BASH_VERSINFO[0]:-0} -eq 4 && ${BASH_VERSINFO[1]:-0} -ge 4 || ${BASH_VER \builtin compgen -A directory -- "${COMP_WORDS[-1]}" || \builtin true ) # If there is a space after the last word, use interactive selection. - elif [[ -z ${COMP_WORDS[-1]} ]]; then + elif [[ -z ${COMP_WORDS[-1]} ]] && [[ ${COMP_WORDS[-2]} != "${__zoxide_z_prefix}"?* ]]; then \builtin local result # shellcheck disable=SC2312 result="$(\command zoxide query --exclude "$(__zoxide_pwd)" -i -- "{{ "${COMP_WORDS[@]:1:${#COMP_WORDS[@]}-2}" }}")" &&