Improve bash completions

This commit is contained in:
Ajeet D'Souza 2023-05-06 11:15:33 +05:30
parent 8d3d6d8bcf
commit 83946ab63a
2 changed files with 4 additions and 3 deletions

View File

@ -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

View File

@ -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}" }}")" &&