1 # brew-completion: bash completion function for Homebrew (brew command)
2 # Copyright (c)2010 Alexander Barton <alex@barton.de>
3 # This is free software and published under the terms of the GNU
4 # General Public License, see the file COPYING for details.
10 prefix=`brew --prefix`
11 formulae=`brew search`
12 COMPREPLY=( $(compgen -W '$formulae' -- "$1") )
15 _brew_formula_installed()
19 prefix=`brew --prefix`
21 COMPREPLY=( $(compgen -W '$formulae' -- "$1") )
30 prev=${COMP_WORDS[COMP_CWORD-1]}
33 declare -i i=$COMP_CWORD-1
34 while [ $i -gt 0 ]; do
35 if [[ ${COMP_WORDS[i]} != -* \
36 || ${COMP_WORDS[i]} == "--cache" \
37 || ${COMP_WORDS[i]} == "--cellar" \
38 || ${COMP_WORDS[i]} == "--prefix" ]]; then
46 "cleanup"|"edit"|"home"|"log"|"prune" \
47 |"--cache"|"--cellar"|"--prefix")
51 "link"|"remove"|"uninstall"|"unlink")
52 _brew_formula_installed "$cur"
56 if [[ "$cur" == -* ]]; then
57 COMPREPLY=( $(compgen -W '--macports' \
63 if [[ "$cur" == -* ]]; then
64 COMPREPLY=( $(compgen -W '--github' \
72 if [[ "$cur" == -* ]]; then
73 COMPREPLY=( $(compgen -W '--HEAD -H \
74 --debug -d --interactive -i
75 --verbose -v --ignore-dependencies' \
83 if [[ "$cur" == -* ]]; then
84 COMPREPLY=( $(compgen -W '
85 --unbrewed' -- "$cur") )
96 if [[ "$cur" == -* ]]; then
97 COMPREPLY=( $(compgen -W '--cache --cellar --help --prefix \
98 --version -v -H' -- "$cur") )
99 elif [ "$cmd" = "" ]; then
100 COMPREPLY=( $(compgen -W 'cleanup create edit home info \
101 install link list log outdated prune remove search \
102 uninstall unlink update' -- "$cur") )
105 complete -F _brew brew