diff --git a/CHANGELOG.md b/CHANGELOG.md index 846e246..2e3cdf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - manpages: moved to `man/man1/*.1`. +### Fixed + +- Rename `_z` completion function to avoid conflicts with other shell plugins. + ## [0.8.0] - 2021-12-25 ### Added diff --git a/README.md b/README.md index 38ec3ff..fec0485 100644 --- a/README.md +++ b/README.md @@ -241,7 +241,7 @@ eval "$(zoxide init zsh)" ``` For completions to work, the above line must be added _after_ `compinit` is -called. +called. You may have to rebuild your cache by running `rm ~/.zcompdump*; compinit`. diff --git a/templates/bash.txt b/templates/bash.txt index 3ec424a..8aff54f 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -123,7 +123,7 @@ if [[ ${BASH_VERSINFO:-0} -ge 4 && :"${SHELLOPTS}": =~ :(vi|emacs): && ${TERM} ! # Use `printf '\e[5n'` to redraw line after fzf closes. \builtin bind '"\e[0n": redraw-current-line' &>/dev/null - function _{{cmd}}() { + function __zoxide_z_complete() { # Only show completions when the cursor is at the end of the line. [[ {{ "${#COMP_WORDS[@]}" }} -eq $((COMP_CWORD + 1)) ]] || return @@ -140,7 +140,7 @@ if [[ ${BASH_VERSINFO:-0} -ge 4 && :"${SHELLOPTS}": =~ :(vi|emacs): && ${TERM} ! fi } - \builtin complete -F _{{cmd}} -o nospace -- {{cmd}} + \builtin complete -F __zoxide_z_complete -o nospace -- {{cmd}} fi {%- when None %} diff --git a/templates/zsh.txt b/templates/zsh.txt index 16a5069..6f01d24 100644 --- a/templates/zsh.txt +++ b/templates/zsh.txt @@ -109,8 +109,8 @@ function {{cmd}}i() { } if [[ -o zle ]]; then - __zoxide_unset _{{cmd}} - function _{{cmd}}() { + __zoxide_unset __zoxide_z_complete + function __zoxide_z_complete() { # Only show completions when the cursor is at the end of the line. # shellcheck disable=SC2154 [[ "{{ "${#words[@]}" }}" -eq "${CURRENT}" ]] || return @@ -129,19 +129,19 @@ if [[ -o zle ]]; then fi } - __zoxide_unset _{{cmd}}_helper - function _{{cmd}}_helper() { + __zoxide_unset __zoxide_z_complete_helper + function __zoxide_z_complete_helper() { \builtin local result="${__zoxide_z_prefix}${__zoxide_result}" # shellcheck disable=SC2296 [[ -n "${__zoxide_result}" ]] && LBUFFER="${LBUFFER}${(q-)result}" \builtin zle reset-prompt } - \builtin zle -N _{{cmd}}_helper - \builtin bindkey "\e[0n" _{{cmd}}_helper + \builtin zle -N __zoxide_z_complete_helper + \builtin bindkey "\e[0n" __zoxide_z_complete_helper if [[ "${+functions[compdef]}" -ne 0 ]]; then \compdef -d {{cmd}} - \compdef _{{cmd}} {{cmd}} + \compdef __zoxide_z_complete {{cmd}} fi fi