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.
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?
Unless if have other occurrences that I'm not noticing, git-core
package provides /usr/share/bash-completion/completions/git
:
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.
here you go
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
?
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.
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
@paoloantinori Can you file a bug upstream please?
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.
Most helpful comment
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.