Browse code

adding homebrew completions - and a function dir

Erik Kastner authored on 26/10/2009 at 04:47:23
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,61 @@
0
+#compdef brew
1
+
2
+# copied from _fink
3
+
4
+_brew_all_formulae() {
5
+  formulae=(`brew search`)
6
+}
7
+
8
+_brew_installed_formulae() {
9
+  installed_formulae=(`brew list`)
10
+}
11
+
12
+local -a _1st_arguments
13
+_1st_arguments=(
14
+  'install:install a formula'
15
+  'remove:remove a formula'
16
+  'search:search for a formula (/regex/ or string)'
17
+  'list:list files in a formula or not-installed formulae'
18
+  'link:link a formula'
19
+  'unlink:unlink a formula'
20
+  'home:visit the homepage of a formula or the brew project'
21
+  'info:information about a formula'
22
+  'prune:remove dead links'
23
+  'update:freshen up links'
24
+  'log:git commit log for a formula'
25
+  'create:create a new formula'
26
+  'edit:edit a formula'
27
+)
28
+
29
+local expl
30
+local -a formula installed_formulae
31
+
32
+_arguments \
33
+  '(-v --verbose)'{-v,--verbose}'[verbose]' \
34
+  '(--version)--version[version information]' \
35
+  '(--prefix)--prefix[where brew lives on this system]' \
36
+  '(--cache)--cache[brew cache]' \
37
+  '*:: :->subcmds' && return 0
38
+
39
+if (( CURRENT == 1 )); then
40
+  _describe -t commands "brew subcommand" _1st_arguments
41
+  return
42
+fi
43
+
44
+case "$words[1]" in
45
+  list)
46
+    _arguments \
47
+      '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
48
+      '1: :->forms' &&  return 0
49
+      
50
+      if [[ "$state" == forms ]]; then
51
+        _brew_installed_formulae
52
+        _requested installed_formulae expl 'installed formulae' compadd -a installed_formulae
53
+      fi ;;
54
+  install|home|log|info)
55
+    _brew_all_formulae
56
+    _wanted formulae expl 'all formulae' compadd -a formulae ;;
57
+  remove|edit|xo)
58
+    _brew_installed_formulae
59
+    _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
60
+esac
... ...
@@ -1,5 +1,8 @@
1 1
 # Initializes Oh My Zsh
2 2
 
3
+# add a function path
4
+fpath=($ZSH/functions $fpath)
5
+
3 6
 # Load all of the config files in ~/oh-my-zsh that end in .zsh
4 7
 # TIP: Add files you don't want in git to .gitignore
5 8
 for config_file ($ZSH/lib/*.zsh) source $config_file