hub
hub copied to clipboard
Auto-completion stop to work with Git version 2.18.0
I use macOS and Homebrew to install/update Git and hub.
After upgrade Git (brew upgrade git
) from version 2.17.1
to 2.18.0
the auto-completion of the GitHub commands provided by hub (browse
, ci-status
, compare
, etc...) stop to work in Bash.
Previous configuration with auto-completion working:
$ git --version
git version 2.17.1
hub version 2.4.0
Current configuration with auto-completion not working:
$ git --version
git version 2.18.0
hub version 2.4.0
I was able to reproduce the error in two different machines.
Thank you for reporting! I can see the same.
@mislav I'm still having this issue using hub 2.5.0:
$ hub version
git version 2.18.0
hub version 2.5.0
$ cat ~/.bash_profile
source /usr/local/etc/bash_completion.d/git-completion.bash
source /usr/local/etc/bash_completion.d/hub.bash_completion.sh
It's working for me after install the new version of hub (2.5.0) with Homebrew.
@davishmcclurg Unfortunately, the new workaround in hub 2.5.0 will only work when hub is aliased as git
, even if the command invoked is hub
. This is sub-optimal and PRs to improve this are welcome.
# without alias
$ hub p
pull push
$ alias git=hub
$ hub p
pr pull pull-request push
Ok, that works. Thanks @mislav!
Gonna reopen this until alias is no longer needed
I did set alias git=hub
.
But, zsh compiletoin is not work.
Environment
❯ brew info zsh-completion
zsh-completions: stable 0.27.0, HEAD
❯ hub --version
git version 2.18.0
hub version 2.5.0
Should I talk about zsh-completion here?
Should I talk about zsh-completion here?
zsh-completion is not relevant. But whether you have the Git-provided _git
completion or the _zsh
-provided one is. What is your zsh $fpath
value, and is /usr/local/share/zsh/site-functions/_zsh
present, and if so, what does it point to?
hub folks: what do you think about extending hub --version
to examine its zsh environment and print an indication of which source of _zsh
completion functions it's working with?
Alias stops working for me recently.
$ type -f git
git is aliased to `hub'
$ hub pu
pull push
$ hub pull-request -
-F -M -a -b -f -h -i -l -m
Same here @ushuz
$ git --version
git version 2.22.0
hub version 2.12.0
I get this with hub 2.12.0 and bash 3.2 on macOS:
$ alias git=hub
$ hub pu
pull pull-request push
@ushuz @arturoherrero Could you provide more information about your shell, OS, and how you installed hub and shell completions? Thanks
Ah I see it now when I upgrade to git 2.22:
$ hub pu
pull push
git must have changed something again in how they organize their shell completions. I think it's too risky that we build on top of their completion script, but then again I have no other ideas on how to hook into git's completions to inject extra hub stuff.
Hotfix
alias __git=hub
FYI: https://github.com/git/git/blob/7c20df8/contrib/completion/git-completion.bash#L1029
@yasuoza I suspect that will break some use cases because: https://github.com/git/git/blob/7c20df8/contrib/completion/git-completion.bash#L90
Just in case this saves anyone time - these tips may seem obvious, but so many people including myself have been struggling to get this working.
-
The alias workaround must occur before the sourcing of any
git-completion
script (e.g., in~/.bash_profile
). -
In your excitement, don't forget to
source ~/.bash_profile
(or whatever your shell config file is), or open a new terminal window before testing it out. -
With the alias workaround, you don't need anything like this:
if [ -f $(brew --prefix)/etc/bash_completion.d/hub.bash_completion.sh ]; then
. $(brew --prefix)/etc/bash_completion.d/hub.bash_completion.sh
fi
@mislav Any update on #1995?
Neither works here. This is macOS 11.4 on a Silicon M1 machine.
This is with home-brew in /opt/homebrew, and with
0:00 ~ > hub version
git version 2.31.1
hub version refs/heads/master
The hub version is the latest one from home-brew, I don't know why it is listed as "refs/heads/master", but apparently this is 2.14.2.
0:00 ~ > brew info hub
hub: stable 2.14.2 (bottled), HEAD
I had to disable asyncpreemptoff because of https://github.com/golang/go/issues/42700
Also doesn't work with the very latest git version on home-brew (2.32.0). I accidentally also discovered that running hub
, even without any arguments and any attempt to autocomplete, kills my iTerm session, when both __git
and git
are aliased to hub
.
hub --version
git version 2.32.1 (Apple Git-133)
hub version refs/heads/master
I have this
alias git=hub
when I tab on this
git [cursor]
it gives
git (eval):1: command not found: _hub
(eval):1: command not found: _hub
(eval):1: command not found: _hub
I don't know how to fix it
I am using mac os silicon M1
When i remove alias
git
zsh: do you wish to see all 154 possibilities (154 lines)?
git working fine
hub (eval):1: command not found: _hub
(eval):1: command not found: _hub
(eval):1: command not found: _hub
hub gives me an error.
I think this is related to zsh autocomplete but not sure how to solve it.