Brew Plugin
Merge completion with official brew completion. Add a helper to link official
completion into oh-my-zsh plugin (without overwriting). Add an alias to list
installed brews. Add brews to the path (in a somewhat strange way).
Diff
1diff --git a/plugins/brew/_brew b/plugins/brew/_brew
2index cee1e25f0bdbaae3808392f6bc678e22f653ec80..1dcf0a4bff26c50eec9a8023695cfe409db6053d 100644
3--- a/plugins/brew/_brew
4+++ b/plugins/brew/_brew
5@@ -25,10 +25,12 @@ _1st_arguments=(
6 'link:link a formula'
7 'list:list files in a formula or not-installed formulae'
8 'log:git commit log for a formula'
9+ 'missing:check all installed formuale for missing dependencies.'
10 'outdated:list formulas for which a newer version is available'
11 'prune:remove dead links'
12 'remove:remove a formula'
13 'search:search for a formula (/regex/ or string)'
14+ 'server:start a local web app that lets you browse formulae (requires Sinatra)'
15 'unlink:unlink a formula'
16 'update:freshen up links'
17 'upgrade:upgrade outdated formulae'
18@@ -36,10 +38,14 @@ _1st_arguments=(
19 )
2021 local expl
22-local -a formula installed_formulae
23+local -a formulae installed_formulae
2425 _arguments \
26- '(-v --verbose)'{-v,--verbose}'[verbose]' \
27+ '(-v)-v[verbose]' \
28+ '(--cellar)--cellar[brew cellar]' \
29+ '(--config)--config[brew configuration]' \
30+ '(--env)--env[brew environment]' \
31+ '(--repository)--repository[brew repository]' \
32 '(--version)--version[version information]' \
33 '(--prefix)--prefix[where brew lives on this system]' \
34 '(--cache)--cache[brew cache]' \
35@@ -51,20 +57,24 @@ if (( CURRENT == 1 )); then
36 fi
3738 case "$words[1]" in
39- list)
40+ search|-S)
41+ _arguments \
42+ '(--macports)--macports[search the macports repository]' \
43+ '(--fink)--fink[search the fink repository]' ;;
44+ list|ls)
45 _arguments \
46 '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
47+ '(--versions)--versions[list all installed versions of a formula]' \
48 '1: :->forms' && return 0
4950 if [[ "$state" == forms ]]; then
51 _brew_installed_formulae
52- _requested installed_formulae expl 'installed formulae' compadd -a installed_formulae
53+ _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae
54 fi ;;
55- install|home|log|info|uses|cat|deps)
56+ install|home|homepage|log|info|abv|uses|cat|deps|edit|options)
57 _brew_all_formulae
58 _wanted formulae expl 'all formulae' compadd -a formulae ;;
59- remove|edit|xo)
60+ remove|rm|uninstall|unlink|cleanup|link|ln)
61 _brew_installed_formulae
62 _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
63 esac
64-
65diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh
66new file mode 100644
67index 0000000000000000000000000000000000000000..f584a4684fe347c9be9070e1862afd3809138670
68--- /dev/null
69+++ b/plugins/brew/brew.plugin.zsh
70@@ -0,0 +1,13 @@
71+# Move /usr/local/bin (path where brews are linked) to the front of the path
72+# This will allow us to override system binaries like ruby with our brews
73+# TODO: Do this in a more compatible way.
74+# What if someone doesn't have /usr/bin in their path?
75+export PATH=`echo $PATH | sed -e 's|/usr/local/bin||' -e 's|::|:|g'` # Remove /usr/local/bin
76+export PATH=`echo $PATH | sed -e 's|/usr/bin|/usr/local/bin:&|'` # Add it in front of /usr/bin
77+export PATH=`echo $PATH | sed -e 's|/usr/bin|/usr/local/sbin:&|'` # Add /usr/local/sbin
78+
79+alias brews='brew list -1'
80+
81+function brew-link-completion {
82+ ln -s "$(brew --prefix)/Library/Contributions/brew_zsh_completion.zsh" "$ZSH/plugins/brew/_brew.official"
83+}