Try typing this on OSX: hub pull
and then TAB. The pull-request
isn't available as possible option. When on Linux it works flawlessly.
The pull request functionality works, it's just auto-complete that doesn't work for it.
How did you install hub? Did you do any additional steps to enable tab-completion?
I've installed hub using Homebrew (http://brew.sh/). The bash auto-complete script used on linux and OSX is the same.
Here is OSX result of hub TAB
(you can scroll right):
add ci fsck pf shortlog
am citool gc pff show
annotate clean get-tar-commit-id pull show-branch
apply clone grep push squash
archive co gui rbm st
bi column help rebase stage
bisect commit imap-send reflog stash
blame config init relink status
bp credential instaweb remote submodule
br credential-osxkeychain log repack subtree
branch describe merge replace svn
bundle diff mergetool request-pull tag
check-mailmap difftool mv reset undo
checkout fetch name-rev revert verify-commit
cherry filter-branch notes rm whatchanged
cherry-pick format-patch p4 send-email
Here is Linux result of hub TAB
(you can scroll right):
add checkout describe instaweb reflog stage
alias cherry diff log relink stash
am cherry-pick difftool merge remote status
annotate ci fetch mergetool repack submodule
apply ci-status filter-branch mv replace svn
archive citool fork name-rev request-pull sync.sh
bi clean format-patch notes reset tag
bisect clone fsck p4 revert undo
blame co gc pf rm verify-commit
bp column get-tar-commit-id pff send-email whatchanged
br commit grep pull shortlog
branch compare gui pull-request show
browse config help push show-branch
bundle create imap-send rbm squash
check-mailmap credential init rebase st
Since pressing TAB does something, then I guess hub auto-complete script works. However it appears, that none of hub-specific commands are displayed. I can see all my custom aliases though (e.g. rbm
, st
)
The bash autocompletion engine was installed by Homebrew as well.
Is your ~/.bash_profile
set to enable completion scripts from Homebrew?
source "$(brew --prefix)/etc/bash_completion"
brew list hub
include hub.bash_completion.sh
?Was the completion script symlinked by Homebrew?
ls -l "$(brew --prefix)"/etc/bash_completion.d/ | grep hub
Is your ~/.bash_profile set to enable completion scripts from Homebrew?
Yes.
$> brew list hub
/usr/local/Cellar/hub/1.12.2/bin/hub
/usr/local/Cellar/hub/1.12.2/etc/bash_completion.d/hub.bash_completion.sh
/usr/local/Cellar/hub/1.12.2/share/man/man1/hub.1
/usr/local/Cellar/hub/1.12.2/share/zsh/site-functions/_hub
$> ls -l "$(brew --prefix)"/etc/bash_completion.d/ | grep hub
lrwxr-xr-x 1 alex admin 68 Aug 15 10:45 hub.bash_completion.sh -> ../../Cellar/hub/1.12.2/etc/bash_completion.d/hub.bash_completion.sh*
I believe auto-completion script is connected, because otherwise I'll be getting none suggestions at all. What might be happening is that hub.bash_completion.sh
decides not to auto-complete pull-request
and other Hub specific commands for some reason.
What might be happening is that hub.bash_completion.sh decides not to auto-complete pull-request and other Hub specific commands for some reason.
That's unlikely. What's more likely is that git
gets run before completion scripts from Homebrew are loaded, somehow prematurely triggering the loading of git core completions.
Can you move source "$(brew --prefix)/etc/bash_completion"
as early in your bash_profile as possible and restart your shell? Ideally no git commands should occur before loading completions. Just some thing to try.
I don't know why, but symlined version of auto-complete script from hub.bash_completion.sh -> ../../Cellar/hub/1.12.2/etc/bash_completion.d/hub.bash_completion.sh
wasn't working as expected. I've copied actual SH file to my home folder's bash_completion.d
folder and it started to work as expected.
Actually I had same solution on Linux and that's why it worked.
The symlinked version should work identically. That's the nature of
symlinks鈥攖hey shouldn't be distinguishable from normal files (in most
cases). Homebrew is the way I've got it set up and it works. Maybe you
could try restoring it back to the symlink in Homebrew and try debugging
what might be wrong with it.
The __git_list_all_commands
function should return hub + git native commands I suppose. When I run it on Linux I get this:
pull-request
fork
create
browse
compare
ci-status
add
merge-octopus
merge-one-file
am
merge-ours
annotate
merge-recursive
apply
merge-resolve
archimport
merge-subtree
archive
merge-tree
bisect
mergetool
mktag
blame
mktree
branch
mv
bundle
name-rev
cat-file
notes
check-attr
p4
check-ignore
pack-objects
check-mailmap
pack-redundant
check-ref-format
pack-refs
checkout
patch-id
checkout-index
peek-remote
cherry
prune
cherry-pick
prune-packed
citool
pull
clean
push
clone
quiltimport
column
read-tree
commit
rebase
commit-tree
receive-pack
config
reflog
count-objects
relink
credential
remote
credential-cache
remote-ext
remote-fd
credential-store
remote-ftp
cvsexportcommit
remote-ftps
cvsimport
remote-http
cvsserver
remote-https
daemon
remote-testgit
describe
remote-testsvn
diff
repack
diff-files
replace
diff-index
repo-config
diff-tree
request-pull
difftool
rerere
reset
fast-export
rev-list
fast-import
rev-parse
fetch
revert
fetch-pack
rm
filter-branch
send-email
fmt-merge-msg
send-pack
for-each-ref
format-patch
shell
fsck
shortlog
fsck-objects
show
gc
show-branch
get-tar-commit-id
show-index
grep
show-ref
gui
stage
stash
hash-object
status
help
stripspace
http-backend
submodule
http-fetch
svn
http-push
symbolic-ref
imap-send
tag
index-pack
tar-tree
init
unpack-file
init-db
unpack-objects
instaweb
update-index
log
update-ref
lost-found
update-server-info
ls-files
upload-archive
ls-remote
upload-pack
ls-tree
var
mailinfo
verify-commit
mailsplit
verify-pack
merge
verify-tag
merge-base
merge-file
whatchanged
merge-index
write-tree
sync.sh
however, when I run it on OSX I get this:
pull-request
fork
create
browse
compare
ci-status
alias
pull-request
fork
create
browse
compare
ci-status
-bash: __git_list_all_commands_without_hub_without_hub: command not found
The Bash version on OSX is (where it doesn't work):
GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)
Copyright (C) 2007 Free Software Foundation, Inc.
The Bash version on Linux is (where it works):
GNU bash, version 4.1.10(2)-release (x86_64-slackware-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
I guess there is something incorrect with syntax used to declare that __git_list_all_commands_without_hub_without_hub
function.
Maybe sed
doesn't work the same (see https://github.com/github/hub/blob/master/etc/hub.bash_completion.sh#L8).
I've just noticed that function used has _without_hub
repeated 2 times at the end. I guess that is the problem. The auto-completion script is invoked only once.
I think I understand what's happening. I have both Hub and Git installed via Homebrew. The Hub creates __git_list_all_commands
function and then Git replaces it with it's own. That's why including same Hub auto-complete script again from ~/.bash_completion.d
folder helps (it just overwrites what Git has created before as it supposed to).
Yes, that was it. I had this:
~/.bash_autocompletion.d
which I've used before I've started to use Git from Homebrew, which already had it's own auto-complete scriptI removed later script and all started to work.
Great. Thanks!
This is not working for me, tried adding:
if [ -f $(brew --prefix)/etc/hub.bash_completion.d ]; then
. $(brew --prefix)/etc/hub.bash_completion.d/hub.bash_completion.sh
fi
to my .bash_profile
but still not working.
how can I do the setup?
@danielgomezrico Did you load git's own bash completion script before loading hub's? I don't know exactly where it is for Apple Git-63, but it should be somewhere on the system.
@mislav you mean using something like this? https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
No, I tried tag with git command but theres no autocomplete for it neither.
@danielgomezrico Well, the way to load hub's completion is to first load git's own completion (it should complete git commands in the terminal), then when you verify that works, load hub's completion and restart the shell again.
I installed both Git and Hub through Homebrew. The auto completion worked just fine until recently. hub [TAB]
only gives me git
's command but not hub
's. I'm not sure the cause, the Apple Git, Homebrew Git and Hub had all been upgraded in the meantime.
$聽/usr/local/bin/hub --version
git version 2.18.0
hub version 2.5.0
$聽/usr/bin/git --version
git version 2.15.1 (Apple Git-101)
@ushuz See https://github.com/github/hub/issues/1792#issuecomment-403413131
Most helpful comment
@ushuz See https://github.com/github/hub/issues/1792#issuecomment-403413131