Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

zsh option `complete_aliases` breaks completion script #363

Open
mislav opened this Issue · 5 comments

3 participants

@mislav
Owner

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
Owner

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
Owner

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

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

@mislav
Owner

@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

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

@jasonlong jasonlong referenced this issue in sorin-ionescu/prezto
Closed

Use Git aliases + branch name completion? #815

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.