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

Autocompletion does not work for git aliases #210

Open
shipstar opened this issue Sep 6, 2015 · 4 comments
Open

Autocompletion does not work for git aliases #210

shipstar opened this issue Sep 6, 2015 · 4 comments

Comments

@shipstar
Copy link

shipstar commented Sep 6, 2015

I've never been able to get autocompletion working for git aliases I've created. My shell-fu is very weak, but I've spent several days debugging this over the course of months to no avail. Hopefully I'm just doing something stupid.

For comparison, here's what git branch <tab> looks like:

➜  .dotfiles git:(master) ✗ git branch
HEAD                              master                            origin/git-post-push-compare-url
ORIG_HEAD                         origin/HEAD                       origin/master

and here's gb <tab> (my git branch alias):

➜  .dotfiles git:(master) ✗ gb
LICENSE.md     atom.symlink/  clojure/       git/           js/            ruby/          system/        zsh/
README.md      bin/           functions/     homebrew/      osx/           script/        vim/

I added a couple debug messages to the completion script, and it looks like the test for file existence is failing. The following prints "Here," but never "There":

# completion.zsh
completion='$(brew --prefix)/share/zsh/site-functions/_git'

echo "Here"
if test -f $completion
then
  echo "There"
  source $completion
fi

If I cd into that directory and ls -l, I see the following:

➜  site-functions git:(master) ls -l
total 28
lrwxr-xr-x 1 kshipley admin 61 May  7 14:15 _docker -> ../../../Cellar/docker/1.6.0/share/zsh/site-functions/_docker
lrwxr-xr-x 1 kshipley admin 58 Aug 17 23:10 _flow -> ../../../Cellar/flow/0.14.0/share/zsh/site-functions/_flow
lrwxr-xr-x 1 kshipley admin 55 Sep  6 08:58 _git -> ../../../Cellar/git/2.5.1/share/zsh/site-functions/_git
lrwxr-xr-x 1 kshipley admin 60 Mar 25 11:42 _hg -> ../../../Cellar/mercurial/3.3.2/share/zsh/site-functions/_hg
lrwxr-xr-x 1 kshipley admin 55 Sep  6 09:50 _hub -> ../../../Cellar/hub/2.2.1/share/zsh/site-functions/_hub*
lrwxr-xr-x 1 kshipley admin 62 Jan 11  2015 _lein -> ../../../Cellar/leiningen/2.5.0/share/zsh/site-functions/_lein
lrwxr-xr-x 1 kshipley admin 70 Sep  6 08:58 git-completion.bash -> ../../../Cellar/git/2.5.1/share/zsh/site-functions/git-completion.bas

(And the files do exist on the other side of the symlink.)

I reinstalled git and hub this morning, figured out that ZSH was pointing to the Mac-default instead of my Homebrew-installed version, and tried every little bit of cleanup I could think of, but still no luck.

Here's my fork of the repo. I've made a few small tweaks (mostly removing things), so it's possible I removed something important.

Any ideas?

@holman
Copy link
Owner

holman commented Sep 6, 2015

Yeah, I don't know of a way to carry autocompletion through aliases. Would be dope tho.

@shipstar
Copy link
Author

shipstar commented Sep 6, 2015

Well, I feel better at least! Here's hoping someone out there in the ether has solved this.

@shipstar
Copy link
Author

shipstar commented Sep 7, 2015

As far as I can tell, it looks like setopt complete_aliases is the culprit. When I comment out that line, alias autocompletion works with no additional changes.[1]

I don't know enough about complete_aliases to know what else is affected by this, but figured I'd leave it here for future spelunkers.

[1] With one minor quirk -- the first time I <tab> to autocomplete, it shows branch autocompletions and file/dir autocompletions.

@marionzualo
Copy link

@shipstar You can have autocompletion if you use git aliases instead of normal aliases. The drawback I see is that you will have to manually type git {your_alias} instead of just your_alias.

ajdexter pushed a commit to ajdexter/dotfiles that referenced this issue Jan 5, 2019
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

3 participants