diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d7d60b..2f86b66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,8 +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. -- Bash/Fish: providing `z` completions when the last argument starts with `z!`. -- Bash/Fish: attempting to `cd` when the last argument is `z!`. +- Bash/Fish/Zsh: providing `z` completions when the last argument starts with `z!`. +- Bash/Fish/Zsh: attempting to `cd` when the last argument is `z!`. ## [0.9.0] - 2023-01-08 diff --git a/templates/zsh.txt b/templates/zsh.txt index 744c49f..20ddd5c 100644 --- a/templates/zsh.txt +++ b/templates/zsh.txt @@ -61,7 +61,7 @@ function __zoxide_z() { __zoxide_cd ~ elif [[ "$#" -eq 1 ]] && { [[ -d "$1" ]] || [[ "$1" = '-' ]] || [[ "$1" =~ ^[-+][0-9]$ ]]; }; 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}}" }}" @@ -88,10 +88,10 @@ if [[ -o zle ]]; then if [[ "{{ "${#words[@]}" }}" -eq 2 ]]; then _files -/ - elif [[ "${words[-1]}" == '' ]]; then + elif [[ "${words[-1]}" == '' ]] && [[ "${words[-2]}" != "${__zoxide_z_prefix}"?* ]]; then \builtin local result # shellcheck disable=SC2086,SC2312 - if result="$(\command zoxide query --exclude "$(__zoxide_pwd)" -i -- ${words[2,-1]})"; then + if result="$(\command zoxide query --exclude "$(__zoxide_pwd)" --interactive -- ${words[2,-1]})"; then result="${__zoxide_z_prefix}${result}" # shellcheck disable=SC2296 compadd -Q "${(q-)result}"