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

Add brew bundle completions #225

Merged
merged 1 commit into from
Feb 15, 2016

Conversation

0xdevalias
Copy link
Contributor

Added the first level of brew bundle autocompletions. Was going to add the --params for each too, but not sure how to make it work.

@holman
Copy link
Owner

holman commented Feb 9, 2016

Nice.

To be honest, this is a section of my dotfiles I totally forgot existed, ha.

Does Homebrew have any "standard" place for all of these, or did you do these manually? For that matter, was the stuff we currently have in here custom as well? I'd prefer to be able to bring in the "full list" if that exists anywhere, otherwise we can just do it ourselves!

@0xdevalias
Copy link
Contributor Author

I just tweaked what was already there, by the looks of it it may have been copied from Homebrew zsh completions So maybe linking to that would be a better way going forward (though not sure it covers the bundle stuff)

Also came across Homebrew/homebrew-completions, and of course there's zsh-users/zsh-completions and oh-my-zsh/tree/master/plugins

@holman
Copy link
Owner

holman commented Feb 9, 2016

You maybe want to just copypasta that in for this pull (and then maybe add some of the bundle stuff too)? I wish it were a bit easier to keep this file pinned to that one, but I doubt it changes all too frequently anyway.

@0xdevalias
Copy link
Contributor Author

(This is a bit of a running mind dump, so hopefully can follow it)

So having a little read further into my dotfiles, it seems that by way of antigen/oh-my-zsh i'm sourcing brew and brew-cask as well.

antigen let's you source from any repo, so the easiest way to stay up to date with the official brew completions should be something like:

antigen bundle Homebrew/homebrew Library/Contributions/brew_zsh_completion.zsh

(which has the less than desirable effect of re-cloning the homebrew repo into .antigen, ~68mb)

Making use of the 'local plugin' features, we could do something like:

antigen bundle $(brew --prefix)/Library/Contributions/brew_zsh_completion.zsh --no-local-clone

It looks like you're currently loading these _completion files in zsh/config, though zsh/zshrc.symlink also mentions autoload, which then runs all the completion.zsh files.

It almost looks like including the _completion files loaded by the config.zsh line might be an old method that you superceded with the completion.zsh method?

Looking at the git/completion.zsh you're manually sourcing from the homebrew zsh completions folder. It could make sense to add this to the FPATH used in config.zsh (for fully automatic loading), or perhaps wrap it up into a nicer helper function to ease loading elsewhere? (though in my trying to do that, it had errors like _default:compcall:12: can only be called from completion function)

Actually, fixing up git/completion.zsh so it actually runs (brew not executed when in ', _git file is a symlink so need -e instead of -f)

completion="$(brew --prefix)/share/zsh/site-functions/_git"

if [[ -e $completion ]]
then
  source $completion
fi

I get the same errors I had when trying to write a nicer 'load' function. Does this work for you? (the rbenv one seems to because the whole thing is directly in completions.zsh)

Loading completions..
  /Users/devalias/.dotfiles/git/completion.zsh
zsh:12: command not found: ___main
_default:compcall:12: can only be called from completion function

So far, cleanest solution to me (ignoring the other bugs) would be to symlink something like this in the functions folder (replacing the current _brew)

ln -s $(brew --prefix)/Library/Contributions/brew_zsh_completion.zsh _brew

@holman
Copy link
Owner

holman commented Feb 10, 2016

I get the same errors I had when trying to write a nicer 'load' function. Does this work for you? (the rbenv one seems to because the whole thing is directly in completions.zsh)

Seems to work for me.

All of this completion stuff is kind of a black box for me; I've never really had the time to sit down and really sort things out. It's mostly — as you've seen — a bunch of things layered on top of each other, and they don't tend to work very well sometimes either (#210).

@0xdevalias
Copy link
Contributor Author

Haha yeah, you and me both tbh. Sunk a bunch of hours into trying to write some better ones, but ultimately have about as little idea what i'm doing with it as when I started.

@holman
Copy link
Owner

holman commented Feb 15, 2016

Just going to go with what you have right now; we can add to it later if people would like. :)

Thanks for looking into all of this!

holman added a commit that referenced this pull request Feb 15, 2016
@holman holman merged commit d69041f into holman:master Feb 15, 2016
@0xdevalias
Copy link
Contributor Author

Sounds good to me :) No worries.

@0xdevalias 0xdevalias deleted the brew-bundle-autocomplete branch February 19, 2016 20:07
tcarlsen pushed a commit to tcarlsen/dotfiles that referenced this pull request Apr 5, 2016
Kilua77 pushed a commit to Kilua77/dotfiles that referenced this pull request Sep 26, 2016
rainkinz pushed a commit to rainkinz/dotfiles that referenced this pull request Oct 10, 2017
adam-cattermole pushed a commit to adam-cattermole/dotfiles that referenced this pull request Dec 7, 2017
program247365 pushed a commit to program247365/dotfiles that referenced this pull request Dec 14, 2017
ajdexter pushed a commit to ajdexter/dotfiles that referenced this pull request 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

Successfully merging this pull request may close these issues.

2 participants