mislav / hub

A command-line tool that makes git easier to use with GitHub.
https://hub.github.com/
MIT License
22.79k stars 2.2k forks source link

zsh option `complete_aliases` breaks completion script #363

Open mislav opened 11 years ago

mislav commented 11 years ago

setopt complete_aliases:

Prevents aliases on the command line from being internally substituted before completion is attempted. The effect is to make the alias a distinct command for completion purposes.

This breaks our current zsh completion. I guess what happens is that it skips _hub completion and loads _git directly?

@goodell tried to solve this in goodell/hub@aa1675d but I feel that this approach is too brittle. Maybe we shouldn't be trying to fix this, and have people disable complete_aliases? Why do people set it in the first place?

So far I've counted the option enabled in Holman's and Pengwynn's dotfiles. It is not enabled in Oh-my-zsh (thanks @blueyed for robbyrussell/oh-my-zsh#241) nor Prezto.

@goodell: Would it be possible to create some kind of "doctor" script which you could eval in your zsh and it will tell you if the completion is hooked up OK and whether you need to fix something about your environment?

goodell commented 11 years ago

I think that's a much better solution. Something like:

$ hub doctor
Please run this command as:
  eval "$(hub doctor)"

$ eval "$(hub doctor)"
✘ Unable to locate "git" command!
✘ "git" is aliased to "hub" but the COMPLETE_ALIASES zsh option is set.
  This will prevent completing hub commands when typing "git <TAB>".  To fix,
  put "unsetopt complete_aliases" in your .zshrc.
$ echo $?
1
$ ... fix issues ...
$ eval "$(hub doctor)"
✔ Your system appears to be properly configured for hub.
$ echo $?
0

I would probably put the ✘ in red and the ✔ in green.

Again, it will probably be a little while before I can implement this.

mislav commented 11 years ago

You don't need to make it so fancy. Just outputting a few plain ol' warnings would do.

Also, I would namespace it under hub hub doctor just as hub hub standalone. This makes sure we don't shadow potential git-doctor command (someone might have it, who knows??) with our helper which is not even a real command.

nixpulvis commented 10 years ago

Having this issue now. unsetopt complete_aliases does not fix it.

mislav commented 10 years ago

@nixpulvis How are you sure that your problem is caused by this zsh option?

Also, you have to unset the option before anything calls out to git. Preferrably very early in your dotfiles.

nixpulvis commented 10 years ago

I'm sorry, it was an issue with my zsh env environment.