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

bash completion not working in Fedora 23 #1041

Open
paoloantinori opened this issue Dec 2, 2015 · 11 comments
Open

bash completion not working in Fedora 23 #1041

paoloantinori opened this issue Dec 2, 2015 · 11 comments
Labels

Comments

@paoloantinori
Copy link

I'm not sure if it's just my environment, but I cannot make bash completion working for hub in Fedora23.

I have actually noticed that I had to put

if [ -f /data/software/ext/hub/etc/hub.bash_completion.sh ]; then
    source /data/software/ext/hub/etc/hub.bash_completion.sh
fi

if [ -f /data/software/ext/hub/bin/hub ]; then
    eval "$(hub alias -s)"
fi

bash_completion sourcing above the alias.

Now I have bash completion, but only with the original git operation and not the augmented list with hub specific ones.

@mislav
Copy link
Owner

mislav commented Dec 2, 2015

Thanks for reporting. Our completion scripts right now are wonky and might not work reliably in different environments. For instance, the completion script is heavily dependent on the base git completion script that should be already sourced in the current environment. What provides your original git completion script, if you can dig up that information?

@paoloantinori
Copy link
Author

Unless if have other occurrences that I'm not noticing, git-core package provides /usr/share/bash-completion/completions/git :

https://gist.github.com/paoloantinori/427db8f32da7c4d748e6

@mislav
Copy link
Owner

mislav commented Dec 2, 2015

Thanks for looking that up. Could you please replace your big paste with a link to a gist? That way conversations threads here stay more readable.

@paoloantinori
Copy link
Author

here you go

@mislav
Copy link
Owner

mislav commented Dec 2, 2015

That git completion script looks fairly standard. Are you sure it gets sourced before the hub completion script?

After the hub completion script is sourced, you still get normal git completions, but not any hub-specific stuff, like git pull-request?

@paoloantinori
Copy link
Author

I have placed an echo entry in both scripts, and surprisingly I see only the output of hub one.

But the autocompleted values comes only from git one and not from hub one.

despite if I invoke in shell

__git_list_all_commands | ag browse
browse

I get the augmented list. It looks like it's not used in later steps.

@purpleidea
Copy link

I can confirm this issue in F23. FWIW, the file is not in /etc/profile.d/ not sure how that bash dir gets picked up in Fedora, or if it runs before/after the git completion stuff. My guess is the ordering is probably the issue.

$ pwd
/etc/bash_completion.d
$ file hub.bash_completion.sh
hub.bash_completion.sh: ASCII text

@purpleidea
Copy link

@paoloantinori Can you file a bug upstream please?

@paoloantinori
Copy link
Author

I have found the reason for this bug. git autocompletion is lazy loaded in Fedora.
If you start a new shell and check for the presence of _git function, it's not there.

But after you trigger the autocompletion at least once, with git [TAB] it becomes available.

Git completion file in Fedora is in /usr/share/bash-completion/completions/git, and explicitely sourcing that file just before hub bash completion fixes the issue.

@kevinoid
Copy link

It appears that this issue was fixed by 57f1ff3, which calls _completion_loader if _git is not declared.

Note: A similar issue has reoccurred in #2684 (due to _git being removed).

@jean
Copy link

jean commented Apr 28, 2021

I have actually noticed that I had to put

The SCOP FAQ pertains:

Q. Where should I install my own local completions?

A. Put them in the completions subdir of $BASH_COMPLETION_USER_DIR (defaults to $XDG_DATA_HOME/bash-completion or ~/.local/share/bash-completion if $XDG_DATA_HOME is not set) to have them loaded automatically on demand when the respective command is being completed. [...]
[...] From this directory, completions are automatically loaded on demand based on invoked commands' names, so be sure to name your completion file accordingly, and to include (for example) symbolic links in case the file provides completions for more than one command. The completion filename for command foo in this directory should be either foo, or foo.bash.

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

No branches or pull requests

5 participants