dsifford / yarn-completion

Bash completion for Yarn
MIT License
277 stars 25 forks source link

Add _get_comp_words_by_ref #6

Closed JonathanUsername closed 7 years ago

JonathanUsername commented 7 years ago

This patch fixed completion on my MacOS machine. Previously it would just list the available commands, but not actually complete them based on the current fragment. Since I'm the sort that hammers tab, this is what I was looking for. I haven't done that many bash completion functions so I'm not certain about how cross-platform this solution is.

Sorry about the whitespace changes, my editor does that by default.

dsifford commented 7 years ago

@JonathanUsername Thanks for the PR.

Very strange. What version of bash-completion do you have installed? What version of bash are you running?

I actually just removed the call to _get_comp_words_by_ref (11516545d23f8f54006590286949fc9b92e8b892) because it's called in the _init_completion function.

JonathanUsername commented 7 years ago

I installed bash-completion via homebrew, I believe it's version 1.3_2. I just updated it and I still don't see the _init_completion function anywhere, neither available from the command line, nor in the main source of the bash-completion script.

$ brew upgrade bash-completion
$ . $(brew --prefix)/etc/bash_completion

I should have looking in the closed issues, is this what you're referring to? https://github.com/dsifford/yarn-completion/issues/1

I was going on this similar issue with the kubernetes CLI (a quick google dredged it up for me) https://github.com/kubernetes/kubernetes/issues/12400#issuecomment-137567835 From which I assumed that _init_completion wasn't available in certain versions of bash-completion.

dsifford commented 7 years ago

@JonathanUsername Aha! Thanks for clarifying. That's helpful. I assume you're using the default mac OS bash version then (which I believe is < v4.x)?

So now it's my understanding that _init_completion came after _get_comp_words_by_ref. Good to know.

Would you mind moving your call to _get_comp_words_by_ref to between these two lines just so we can keep those function calls near each other?

After that, I'd be happy to merge. 😄

JonathanUsername commented 7 years ago

Is that ok @dsifford ? And yes I think I'm in a strange position:

$ sh --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
$ bash --version
GNU bash, version 4.4.5(1)-release (x86_64-apple-darwin15.6.0)

😱

dsifford commented 7 years ago

Looks great to me. Thanks!