Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab completing cd aliases broke in 2.12.0 (worked in 2.11) #1123

Open
3 tasks done
ruohola opened this issue Mar 7, 2024 · 2 comments
Open
3 tasks done

Tab completing cd aliases broke in 2.12.0 (worked in 2.11) #1123

ruohola opened this issue Mar 7, 2024 · 2 comments

Comments

@ruohola
Copy link

ruohola commented Mar 7, 2024

Describe the bug

Autocompleting an cd'able alias (needs Bash option shopt -s cdable_vars to be set) does not work in version 2.12.0

To reproduce

With this .bashrc:

[ -f /opt/homebrew/bin/brew ] && eval "$(/opt/homebrew/bin/brew shellenv)"
[ -f /usr/local/bin/brew ] && eval "$(/usr/local/bin/brew shellenv)"

shopt -s cdable_vars

export bin="${HOME}/.local/bin"

[ -r "$(brew --prefix)/etc/profile.d/bash_completion.sh" ] && . "$(brew --prefix)/etc/profile.d/bash_completion.sh"

with bash-completion@2 2.11 one could type

$ cd b<TAB>

which would get autocompleted to

$ cd bin

but with bash-completion@2 2.12.0 doing the same does not autocomplete any aliases. Autocompletion for normal directories works still fine.

Expected behavior

Autocompleting cd'able aliases should work fine.

Versions (please complete the following information)

  • Operating system name/distribution and version: macOS 14.3.1
  • bash version, echo "$BASH_VERSION": 5.2.26(1)-release
  • bash-completion version, (IFS=.; echo "${BASH_COMPLETION_VERSINFO[*]}"): 2.12.0 (worked on 2.11)

Additional context

I upgraded my brew packages one by one and can confirm that it worked right before upgrading bash-completion@2 and stopped right after that.

Debug trace

N/A

@akinomyoga
Copy link
Collaborator

I seem to be able to reproduce this behavior when the fzf completion is enabled. Do you use fzf? What is the result of the following command?

$ complete -p cd

The fzf completion tries to wrap the completion settings that bash-completion sets. The fzf completion defines its own cd completion and tries to fall back to "the original completion" when the fzf completion doesn't produce the completion candidates. The fzf fetches "the original completion" on fzf's loading time.

In bash-completion 2.11, we defined the completion setting in the main file (bash_completion). In bash-completion 2.12, we started to dynamically load the completion setting for cd on demand. For this reason, fzf doesn't see the original completion set by bash-completion when bash-completion 2.12 is used. Then, fzf instead uses the default setting -o dirnames -o nospace as a part of the original completion. This can be observed by running complete -p cd with bash-completion 2.11 and 2.12:

With shopt -s autocd / bash-completion 2.11
$ complete -p cd
complete -o nospace -v -F _fzf_dir_completion cd

With shopt -s autocd / bash-completion 2.12
$ complete -p cd
complete -o dirnames -o nospace -F _fzf_dir_completion cd

The fzf completion still tries to pick up the dynamically loaded completion setting, but it picks up only the completion function name, and the rest settings seem to be ignored.

@akinomyoga
Copy link
Collaborator

@ruohola Is this problem solved with the latest version of fzf? If yes, can we close the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants