Browse code

fix problems with brew completion

- update plugin architecture
- completion function in $ZSH/functions/brew
- plugins/brew.plugin.zsh only activates

Daniel Schauenberg authored on 20/08/2010 at 16:55:30
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,69 @@
0
+#compdef brew
1
+#autoload
2
+
3
+# imported from the latest homebrew contributions
4
+
5
+_brew_all_formulae() {
6
+  formulae=(`brew search`)
7
+}
8
+
9
+_brew_installed_formulae() {
10
+  installed_formulae=(`brew list`)
11
+}
12
+
13
+local -a _1st_arguments
14
+_1st_arguments=(
15
+  'cat:display formula file for a formula'
16
+  'cleanup:uninstall unused and old versions of packages'
17
+  'create:create a new formula'
18
+  'deps:list dependencies and dependants of a formula'
19
+  'doctor:audits your installation for common issues'
20
+  'edit:edit a formula'
21
+  'home:visit the homepage of a formula or the brew project'
22
+  'info:information about a formula'
23
+  'install:install a formula'
24
+  'link:link a formula'
25
+  'list:list files in a formula or not-installed formulae'
26
+  'log:git commit log for a formula'
27
+  'outdated:list formulas for which a newer version is available'
28
+  'prune:remove dead links'
29
+  'remove:remove a formula'
30
+  'search:search for a formula (/regex/ or string)'
31
+  'unlink:unlink a formula'
32
+  'update:freshen up links'
33
+  'uses:show formulas which depend on a formula'
34
+)
35
+
36
+local expl
37
+local -a formula installed_formulae
38
+
39
+_arguments \
40
+  '(-v --verbose)'{-v,--verbose}'[verbose]' \
41
+  '(--version)--version[version information]' \
42
+  '(--prefix)--prefix[where brew lives on this system]' \
43
+  '(--cache)--cache[brew cache]' \
44
+  '*:: :->subcmds' && return 0
45
+
46
+if (( CURRENT == 1 )); then
47
+  _describe -t commands "brew subcommand" _1st_arguments
48
+  return
49
+fi
50
+
51
+case "$words[1]" in
52
+  list)
53
+    _arguments \
54
+      '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
55
+      '1: :->forms' &&  return 0
56
+
57
+      if [[ "$state" == forms ]]; then
58
+        _brew_installed_formulae
59
+        _requested installed_formulae expl 'installed formulae' compadd -a installed_formulae
60
+      fi ;;
61
+  install|home|log|info|uses|cat|deps)
62
+    _brew_all_formulae
63
+    _wanted formulae expl 'all formulae' compadd -a formulae ;;
64
+  remove|edit|xo)
65
+    _brew_installed_formulae
66
+    _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
67
+esac
68
+
... ...
@@ -1,67 +1,4 @@
1
-#compdef brew
2
-
3
-# imported from the latest homebrew contributions
4
-
5
-_brew_all_formulae() {
6
-  formulae=(`brew search`)
7
-}
8
-
9
-_brew_installed_formulae() {
10
-  installed_formulae=(`brew list`)
11
-}
12
-
13
-local -a _1st_arguments
14
-_1st_arguments=(
15
-  'cat:display formula file for a formula'
16
-  'cleanup:uninstall unused and old versions of packages'
17
-  'create:create a new formula'
18
-  'deps:list dependencies and dependants of a formula'
19
-  'doctor:audits your installation for common issues'
20
-  'edit:edit a formula'
21
-  'home:visit the homepage of a formula or the brew project'
22
-  'info:information about a formula'
23
-  'install:install a formula'
24
-  'link:link a formula'
25
-  'list:list files in a formula or not-installed formulae'
26
-  'log:git commit log for a formula'
27
-  'outdated:list formulas for which a newer version is available'
28
-  'prune:remove dead links'
29
-  'remove:remove a formula'
30
-  'search:search for a formula (/regex/ or string)'
31
-  'unlink:unlink a formula'
32
-  'update:freshen up links'
33
-  'uses:show formulas which depend on a formula'
34
-)
35
-
36
-local expl
37
-local -a formula installed_formulae
38
-
39
-_arguments \
40
-  '(-v --verbose)'{-v,--verbose}'[verbose]' \
41
-  '(--version)--version[version information]' \
42
-  '(--prefix)--prefix[where brew lives on this system]' \
43
-  '(--cache)--cache[brew cache]' \
44
-  '*:: :->subcmds' && return 0
45
-
46
-if (( CURRENT == 1 )); then
47
-  _describe -t commands "brew subcommand" _1st_arguments
48
-  return
49
-fi
50
-
51
-case "$words[1]" in
52
-  list)
53
-    _arguments \
54
-      '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
55
-      '1: :->forms' &&  return 0
56
-
57
-      if [[ "$state" == forms ]]; then
58
-        _brew_installed_formulae
59
-        _requested installed_formulae expl 'installed formulae' compadd -a installed_formulae
60
-      fi ;;
61
-  install|home|log|info|uses|cat|deps)
62
-    _brew_all_formulae
63
-    _wanted formulae expl 'all formulae' compadd -a formulae ;;
64
-  remove|edit|xo)
65
-    _brew_installed_formulae
66
-    _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
67
-esac
1
+# add brew completion function to path
2
+fpath=($ZSH/functions/brew $fpath)
3
+autoload -U compinit
4
+compinit -i